I am restoring a 30GB database from a mysqldump file to an empty database on a new server. When running the SQL from the dump file, the restore starts very quickly and then starts to get slower and slower. Individual inserts are now taking 15+ seconds. The tables are mostly MyISAM with one small InnoDB. The server has no other active connections. SHOW PROCESSLIST;
only shows the insert from the restore (and the show processlist itself).
Does anyone have any ideas what could be causing the dramatic slowdown?
Are there any MySQL variables that I can change to speed the restore while it is progressing?
One thing that may be slowing the process is the key_buffer_size, which is the size of the buffer used for index blocks. Tune this to at least 30% of your RAM or the re-indexing process will probably be too slow.
For reference, if you were using InnoDB and foreign keys, you could also disable foreign key checks and re-enable it at the end (using
SET FOREIGN_KEY_CHECKS=0
andSET FOREIGN_KEY_CHECKS=1
).This link shows what one can do to speed up restoring process.
http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html
One can put put the commands at the top of the dump file
And put these statements at the end of the dump file
This worked for me. Happy restoring :-)
If you have the physical copy of the dump file (the DB directory), you can just copy it to the new server if the new server have the same MySQL version and it will work fine. This work fine with MyISAM and for me I think it is better than restoring the data based on the logical SQL dump file.
This will do:
mysql --init-command="SET SESSION FOREIGN_KEY_CHECKS=0;SET UNIQUE_CHECKS=0;" -u root -p < Backup_Database.mysql
if you have multiple tables chances are you might benefit from mk-parallel-restore.
The only reason I can image why the restore would gradually slow down is indexing. Investigate turning off indexing until the end and then let it do the whole lot at once.
I suggested you ,
AUTOCOMMIT=0
,UNIQUE_CHECKS=0
,FOREIGN_KEY_CHECKS=0
(AND DON'T FORGET TO ROLLBACK THIS CHANGES)mysql -u root -pPasss requests < mydb.sql
Good Luck