最近做一个同步线上数据导dev或者beta环境的小工具.今天遇到一个小异常:
1
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (17610152 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.
原因就是一次插入的数据太大了.Mysql存在数据包最大大小的配置,默认是1M,这里我们的dev环境是16M,但是我这里出现了大于16M的数据packet:
1
2
3
4
5
6
7
mysql> show VARIABLES like '%max_allowed_packet%';
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| max_allowed_packet | 16777216 |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
修改max_allowed_packet:
1.set global max_allowed_packet = 21024 1024*10
2.修改my.conf文件(windows为my.ini)
1
max_allowed_packet = 16M
注意点:
1.保证Master和Slave的max_allowed_packet参数一致(一般都要求所以参数一致);