Hot For Coding

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

MySQL导入sql 10M脚本时出错,如图

full

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]加入:

max_allowed_packet=300M
wait_timeout=200000
interactive_timeout = 200000

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

[root@lizhong 20140323]# /etc/init.d/mysqld restart
Shutting down MySQL.... SUCCESS! 
Starting MySQL. SUCCESS!

再重新导入,一切正常!

分享

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

LINK: https://www.qttc.net/425-mysql-server-has-gone-away.html

NOTE: 原创内容,转载请注明出自琼台博客