### Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (4,246,837 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable.
; Packet for query is too large (4,246,837 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable.; nested exception is com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (4,246,837 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable., path=/user/addList}]
查看 max_allowed_packet 参数:
show VARIABLES like '%max_allowed_packet%';
结果:

修改方法:
1、修改配置文件。编辑my.cnf来修改(windows下my.ini)
max_allowed_packet = 20M
2、在mysql命令行中暂时修改,重新启动MYSQL后,会恢复原来的值。
//这里的数值为字节数,这里改为20M,需要重新登陆客户端起作用
set global max_allowed_packet = 2*1024*1024*10

本文详细解析了MySQL中PacketTooBigException错误的原因,当查询包大小超过默认限制时触发。提供了两种解决策略:一是通过编辑my.cnf或my.ini配置文件调整max_allowed_packet参数;二是在MySQL命令行中临时修改该参数,但需注意重启后会恢复原值。
1947

被折叠的 条评论
为什么被折叠?



