### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.; SQL []; Packet for query is too large (1169 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.; nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
原因是MySQL的max_allowed_packet设置过小引起的,我一开始设置的是1M,后来改为了20M
mysql根据配置文件会限制server接受的数据包大小。有时候大的插入和更新会被max_allowed_packet 参数限制掉,导致失败。
在mysql命令行中执行命令
1、查看当前配置
show VARIABLES like '%max_allowed_packet%';
2、修改配置
set global max_allowed_packet = 2*1024*1024*10; 把max_allowed_packet的值修改的大点、修改完成后mysql重新启动服务,但是项目可能也要重新启动。
3、Linux系统下
在linux下,进入到mysql安装目录下:
进入到:
/usr/local/mysql,找到my.cnf,增加一行
max_allowed_packet = 20M
重启mysql:
service mysql restart
参考文章:https://blog.csdn.net/qq_26824159/article/details/71514506?locationNum=11&fps=1
https://www.cnblogs.com/gmq-sh/p/7096687.html |