mysql Packet for query is too large 警告及解决方案

问题描述:

在mysql客户端刷新数据库时,报出了以下警告:

Packet for query is too large (1290 > 1024). You can change this value on the server by setting the max_allowed_packet'


使用sql语句 show VARIABLES like '%max_allowed_packet%'; 查询结果显示,max_allowed_packet为1024(和上图的结果相印证)。查询mysql官方文档,得知这个1024的单位是bytes,也就是1KB,当向mysql数据库发送的数据包大于1KB,就会报出以上错误。


解决方案:

1. 登录linux服务器,找到mysql的配置文件my.cnf(一般在 /etc/my.cnf,或使用命令 mysql --help | grep my.cnf查询)

2. 修改该文件,添加如下内容(如果有max_allowed_packet,直接修改后面的值即可)

[mysqld]
max_allowed_packet = 4M

3. 使用命令重启mysql数据库:service mysqld start


参考文档: https://dev.mysql.com/doc/refman/5.6/en/packet-too-large.html

猜你喜欢

转载自blog.csdn.net/pansanday/article/details/80817898