mysql max_allowed_packet过小引起的问题
com.mysql.jdbc.PacketTooBigException: Packet for query is too large (5366885 > 4194304)
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (5366885 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3681)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2512)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
... 63 more
通过如下命令增大max_allowed_packet的值,解决值过小导致的问题
set global max_allowed_packet = 1010241024
注意事项:
1、 max_allowed_packet的值最大为1G,设置的值必须为1024的倍数
2、设置完后,需要退出mysql,重新进入才能看到设置后的值
mysql> show variables like 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+--------------------+---------+
1 row in set (0.02 sec)
mysql> set global max_allowed_packet = 10*1024*1024;
Query OK, 0 rows affected (0.00 sec)
设置为10M,退出mysql,然后重新进入, 调用show variables like 'max_allowed_packet';查看是否修改成功
mysql> show variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 10485760 |
+--------------------+----------+
1 row in set (0.01 sec)