一、使用Load data;html
二、mysql
SET autocommit=0; COMMIT;... SQL import statements ...
三、sql
SET unique_checks=0; SET unique_checks=1;... SQL import statements ...
四、code
SET foreign_key_checks=0; SET foreign_key_checks=1;... SQL import statements ...
五、htm
INSERT INTO yourtable VALUES (1,2), (5,5), ...;
六、blog
set innodb_autoinc_lock_mode
to 2 instead of the default value 1get
time mysql -e "set foreign_key_checks=0; set sql_log_bin=0; set unique_checks=0; load data local infile 'infile.txt' into table load_test fields terminated by '\t' lines terminated by '\n' (col1, col2);"it
腳原本源: https://www.percona.com/blog/2008/07/03/how-to-load-large-files-safely-into-innodb-with-load-data-infile/innodb