SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Your SQL statement was too large.

A little harder to test and verify, but MySQL uses a maximum packet site for communications between the server and the client. If this includes large fields (for example BLOB columns), you may be getting a termination of your SQL statement due to size.

By default this is relatively small.

mysql> show global variables like 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1 row in set (0.00 sec)
You can increase, for example to 16M with:

mysql> set global max_allowed_packet=1024102416;
mysql> show global variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)
The good news, is this was the cause for the customer today, and now no more errors!

Be sure to keep this value during MySQL restarts.

my.cnf

[mysqld]
max_allowed_packet = 16M

参考文档:http://ronaldbradford.com/blog/sqlstatehy000-general-error-2006-mysql-server-has-gone-away-2013-01-02/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 假如是晨曦朝露,活力无限,那就去奏一首青春的凯歌,不要畏首畏尾,不要浑浑噩噩,懦弱只会掩盖初阳和煦的光芒,弱冠之年...
    楚地小生阅读 2,256评论 0 4