问题描述
MySQL数据库在新增数据时报错:Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (11007588 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
查询max_allowed_packet参数
show VARIABLES like '%max_allowed_packet%';
结果如下:
Variable_name | Value |
---|---|
max_allowed_packet | 4194304 |
slave_max_allowed_packet | 1073741824 |
解决办法
可以编辑my.cnf来修改(windows下my.ini),在[mysqld]段或者mysql的server配置段进行修改
max_allowed_packet = 1G
修改后重启MySQL查询
show VARIABLES like '%max_allowed_packet%';
结果如下:
Variable_name | Value |
---|---|
max_allowed_packet | 1073741824 |
slave_max_allowed_packet | 1073741824 |