### 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