参数说明:
-e, --extended-insert,长INSERT,多row在一起批量INSERT,提高导入效率,和没有开启 -e 的备份导入耗时至少相差3、4倍,默认开启;用--extended-insert=false关闭。强烈建议开启,通过下面的测试比较就会明白为什么了。
一、默认方式导出,也即--extended-insert=true

[root@localhost ~]# time mysqldump -S /tmp/mysql3307.sock -uroot -p'Zhkj@554996' --single-transaction --extended-insert=true -B -A >testdump.sql
Warning: Using a password on the command line interface can be insecure.
real    0m12.965s
user    0m6.579s
sys    0m1.080s
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# time mysqldump -S /tmp/mysql3307.sock -uroot -p'Zhkj@554996' --single-transaction  -B -A >1testdump.sql
Warning: Using a password on the command line interface can be insecure.
real    0m13.385s
user    0m6.545s
sys    0m1.171s

二、采用参数--extended-insert=false导出全库:

[root@localhost ~]# time mysqldump -S /tmp/mysql3307.sock -uroot -p'Zykj@554996' --single-transaction --extended-insert=false -B -A >2testdump.sql
Warning: Using a password on the command line interface can be insecure.
real    0m16.216s
user    0m8.820s
sys    0m1.282s

三、对比到处的sql文件的大小不一样:

[root@localhost ~]# du -sh testdump.sql  1testdump.sql 2testdump.sql
414M    testdump.sql
414M    1testdump.sql
550M    2testdump.sql

四、对比恢复到数据库所用的时间:
[root@localhost ~]# time mysql -uroot -p -S /tmp/mysql3307.sock < testdump.sql
Enter password:
real    3m34.245s
user    0m9.018s
sys    0m0.361s
[root@localhost ~]# time mysql -uroot -p -S /tmp/mysql3307.sock < 2testdump.sql
Enter password:
real    46m51.702s
user    0m44.712s
sys    0m35.717s


经过上面的一比较,发现导入速度相差非常多。

但是使用--extended-insert=false导出表也有好处
比如数据库中表中已经存在大量数据,那么再往表中导入数据时,如果出现主键数据冲突Duplicate key error,将会导致导入操作失败,但此时如果是使用--extended-insert=false导出表,导入时主键冲突的会报错Duplicate key error,但不冲突的数据仍然能正常导入。