ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 328436
Current database: x_x_x
查看MySQL的正常运行时间
show global status like 'uptime';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Uptime | 22418 |
+---------------+-------+
1 row in set (0.00 sec)
查询错误日志的存储位置:
show variables like '%error';
+---------------+----------------------------------+
| Variable_name | Value |
+---------------+----------------------------------+
| log_error | /home/mysql/mysql5/log/error.log |
+---------------+----------------------------------+
1 row in set (0.00 sec)
查看日志文件
报错信息如下:
xxxx-xx-xxT08:40:05.982603Z 328431 [Note] Aborted connection 328431 to db: 'x_x_x' user: 'root' host: 'xx.xx.xxx.xx' (Got a packet bigger than 'max_allowed_packet' bytes)
MySQL使用最大数据包站站点进行服务器和客户端之间的通信。如果语句包含大字段,则可能由于SQL语句的大小,而被中止。
查看一下允许的最大包大小:
show global variables like 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+--------------------+---------+
1 row in set (0.00 sec)
4194304/1024/1024=4
设置max_allowed_packet
set global max_allowed_packet=1024*1024*64;
注:重启mysql服务后会失效