Solution to slow mysqldump import
The SQL statement exported from MySQL may be very slow during import. It took nearly three hours to import only 0.45 million records. Using a few parameters properly during export can greatly speed up import.
-E uses the multiline INSERT syntax that includes several VALUES lists;
-- Max_allowed_packet = maximum size of the cache for communications between the XXX client/server;
-- Net_buffer_length = XXX TCP/IP and socket communication buffer size, create a line with length up to net_buffer_length.
Note: max_allowed_packet and net_buffer_length cannot be greater than the set value of the target database. Otherwise, an error may occur.
First, determine the parameter value of the target database.
Mysql> show variables like 'max _ allowed_packet ';
Mysql> show variables like 'net _ buffer_length ';
Write the mysqldump command based on the parameter value, for example:
E: \ eis> mysqldump-uroot-p eis_db goodclassification-e -- max_allowed_packet = 1048576 -- net_buffer_length = 16384> good3. SQL
The SQL statements that can be imported in the past two hours can be completed in dozens of seconds.
Importing data using the source * SQL statement in mysql is too slow.
Change the innodb_flush_log_at_trx_commit parameter to 0, and restart the database to be 100 times faster than you did.
Mysql source command import large SQL
Find the my. Ini file in the mysql installation directory and add the following code:
The code is as follows:
Interactive_timeout = 120
Wait_timeout = 120
Max_allowed_packet = 32 M