Packet for query is too large (1025 > 1024) 问题解决

连接MySql时候出现错误:

### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1025 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
; Packet for query is too large (1025 > 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 (1025 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110)

原因是默认的包太小了,修改一下配置即可!

解决方法:

1.查看 max_allowed_packet大小

show VARIABLES like '%max_allowed_packet%';

可以看到默认max_allowed_packet是1024

2. 修改max_allowed_packet,

编辑 vi /etc/my.cnf,在mysqld节点下增加

max_allowed_packet=20M

3.重启MySql,

扫描二维码关注公众号,回复: 9746307 查看本文章
service mysql restart

再次查询可以看到数据已经修改了:

发布了327 篇原创文章 · 获赞 566 · 访问量 263万+

猜你喜欢

转载自blog.csdn.net/vtopqx/article/details/93757201