I have this huge 32 GB SQL dump that I need to import into MySQL. I haven't had to import such a huge SQL dump before. I did the usual:
mysql -uroot dbname < dbname.sql
It is taking too long. There is a table with around 300 million rows, it's gotten to 1.5 million in around 3 hours. So, it seems that the whole thing would take 600 hours (that's 24 days) and is impractical. So my question is, is there a faster way to do this?
Further Info/Findings
- The tables are all InnoDB and there are no foreign keys defined. There are, however, many indexes.
- I do not have access to the original server and DB so I cannot make a new back up or do a "hot" copy etc.
- Setting
innodb_flush_log_at_trx_commit = 2
as suggested here seems to make no (clearly visible/exponential) improvement. - Server stats during the import (from MySQL Workbench): https://imgflip.com/gif/ed0c8.
- MySQL version is 5.6.20 community.
- innodb_buffer_pool_size = 16M and innodb_log_buffer_size = 8M. Do I need to increase these?
Best Answer
Percona's Vadim Tkachenko made this fine Pictorial Representation of InnoDB
You definitely need to change the following
Why these settings ?
.ibd
files. According to MySQL Documentation onConfiguring the Number of Background InnoDB I/O Threads
, each thread can handle up to 256 pending I/O requests. Default for MySQL is 4, 8 for Percona Server. Max is 64.Restart mysql like this
This disables the InnoDB Double Write Buffer
Import your data. When done, restart mysql normally
This reenables the InnoDB Double Write Buffer
Give it a Try !!!
SIDE NOTE : You should upgrade to 5.6.21 for latest security patches.