mysql -u root -p -h 127.0.0.1
password:
mysql>use test;
Database changed
mysql>set names utf8;
mysql> set global innodb_flush_log_at_trx_commit=0;
Query OK, 0 rows affected (0.03 sec)
首先确定目标库的参数值
mysql>show variables like 'max_allowed_packet';
mysql>show variables like 'net_buffer_length';
下面三个修改自己看情况。
mysql> set global max_allowed_packet=1024*1024*20;
Query OK, 0 rows affected (0.00 sec)
mysql> set global bulk_insert_buffer_size=32*1024*1024;
Query OK, 0 rows affected (0.00 sec)
mysql> set global innodb_buffer_pool_size=32*1024*1024;
Query OK, 0 rows affected, 1 warning (0.09 sec)
>mysql source /root/test.sql
导出过慢参考下面
MySQL mysqldump与source导入慢的解决方法
https://blog.csdn.net/qq_37674858/article/details/80090773
MySQL导入大型sql文件太慢的解决办法(亲测有效)
https://blog.csdn.net/ycczbasd/article/details/103181494
Mysql快速导入超大SQL文件(开启事务)
https://blog.csdn.net/qfy1990/article/details/110001041