MySQL导入sql脚本错误:2006 - MySQL server has gone away

小明SEO博客 小明SEO博客,新时代SEO博客

下面我给各位同学介绍在mysql中导入数据库时提示MySQL server has gone away问题的解决方法,如果你碰到mysql提示MySQL server has gone away错误我们可进入参考.

MySQL导入sql脚本错误:2006 - MySQL server has gone away

如一些小脚本很少报错,但最近导入一个10+M的SQL脚本,却重复报错:

Error occured at:2014-03-24 11:42:24

Line no.:85

Error Code: 2006 - MySQL server has gone away

最终找到原因,原来是MySQL导入大批量数据的时候超出了默认允许最大的数据包所以就提示2006 - MySQL server has gone away.

于是找到my.cnf,在[mysqld]加入如下代码:

  1. max_allowed_packet=300M
  2. wait_timeout=200000
  3. interactive_timeout=200000

意思是最大允许数据包300M,等待超时/活动失效时常200000秒,重启MySQL,代码如下:

  1. [root@lizhong20140323]#/etc/init.d/mysqldrestart
  2. ShuttingdownMySQL....SUCCESS!
  3. StartingMySQL.SUCCESS!
  4. //开源软件:phpfensi.com

再重新导入,一切正常.

相关广告
  • MySQL导入sql脚本错误:2006 - MySQL server has gone away MySQL导入sql脚本错误:2006 - MySQL server has gone away MySQL导入sql脚本错误:2006 - MySQL server has gone away
相关阅读

MySQL导入sql脚本错误:2006 - MySQL server has gone away

2019/10/10 17:37:21 | 谷歌SEO算法 | 夫唯SEO视频教程