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/

你可能感兴趣的:(SQLSTATE[HY000]: General error: 2006 MySQL server has gone away)