mysql database restore takes long time
If you're using largely innodb tables increasing the innodb_buffer_pool_size as large as possible (~80-90% system assuming nothing else but mysqld is really consuming ram). This requires a mysqld restart though
Before the reload you can also set innodb_flush_log_at_trx_commit=2 to speed things up. This disables flushing to disk every commit (breaking the D in ACID), but should be fine for a restore. If there's a catastrophic failure during this process you're starting from scratch anyway. Be sure to set this back to one after the restore.
This can be changed dynamically without a bounce
Ensure innodb_flush_method = O_DIRECT is set in your cnf. This requires a restart
Is it getting pegged on CPU in top? If you have a lot of compressed table data that will be inherently slower. There's not much that can be done about this aside from getting a faster core. Multi core wouldn't help you here since the load is done serially anyway.
If you're using spinning disks, if possible ensure the .sql source file is being read from a different set of HDDs. Similarly, during the reload (unless you're trying to let the reload replicate) ensure binary logging and general logging are turned off.
If you're running 5.6 ensure performance schema is not enabled.
This is expected as restore from mysqldump takes longer than taking the backup.
To speedup process consider other backup tools:
xtrabackup. non-blocking for InnoDB, almost as fast as file copy. takes binary backup(=copies InnoDB tablespace).
mydumper. Takes logical backups, but can do it in multiple threads, so it's faster than mysqldump
mylvmbackup. Also very fast, but requires LVM, impacts performance when snapshot is created.
I'd go with option #1.
Usually, mysqldump will take as long to backup as xtrabackup, but much slower when restoring. because xtrabackup copy back by blocks while sql file exported by mysqldump have to execute one bye one.
I am quite sure use some ways could improve import speed, but still will cost you very long long time especially for such a huge database.
So, I truly recommend you install xtrabackup, do a full backup, and then restore to the new server.
or even more simple way, as considering you could to do a cold backup, turn off the mysql server, copy all the files include ibdata1
, ib_logfile*
, mysql folder, etc. to the new location, modify my.cnf
with new location if it is changed. I haven't try it yet, but I didn't see any problem.
the first way is absolutely the best.
I hope this was useful!