mysql 导入数据报2006错误的解决方法

发布时间:2020-12-14编辑:脚本学堂
在mysql中导入数据库时,SQLyog 报错:Error Code: 2006 - MySQL server has gone away,网上说是max_allowed_packet(MySQL的一个参数)设置的值不够大。为大家提供解决方法,供参考。

解决mysql导入数据报2006错误的问题。

1、windows环境
In the MySQL server installation directory,
in my.ini file, add the following line under [mysqld] in SERVER SECTION.
max_allowed_packet = 16M

2、linux环境
Copy the my-xxx.cnf file from /usr/share/mysql to /etc as my.cnf
xxx can be small, medium, large, huge ... depending on the requirement.
$ cp /usr/share/mysql/my-xxx.cnf /etc/my.cnf

In the my.cnf file, change the default
max_allowed_packet = 1M
to
max_allowed_packet = 16M

保存,并重启mysql即可。