连接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,
service mysql restart
再次查询可以看到数据已经修改了: