Slow MySQL import solution bitsCN.com
Slow MySQL import solution
The SQL statement exported by MySQL may be very slow during import. Using a few parameters during export can greatly speed up import.
Import notes:
Using tools such as phpmyadmin or navicat to import data is still quite slow. you can directly use mysql to import data.
The import command is as follows: mysql>-uroot-psupidea name of the database to be imported
: Mysql>-umysql user name-pmysql password name of the database to be imported <要导入mysql的sql文件路径 < p>
In this way, the import will be very fast. the SQL statements that can be imported several hours ago can now be completed in dozens of seconds.
Note:
-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:
Mysql> mysqldump-uroot-psupidea name of the database to be imported goodclassification-e -- max_allowed_packet = 1048576 -- net_buffer_length = 16384> name of the database to be imported. net. SQL
BitsCN.com