【BUG】插入或者更新超过限制后写入数据库失败

 
Error Code: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Usage: mysqldump [OPTIONS] database [tables]   OR mysqldump [OPTIONS] --databa' at line 1
报错: Error Code: 2006 - MySQL server has gone away
 
mysql根据配置文件会限制server接受的数据包大小。
有时候大的插入和更新会受max_allowed_packet 参数限制,导致写入或者更新失败。
 

查看目前配置

SHOW VARIABLES LIKE '%max_allowed_packet%';
 
解决方法
SET GLOBAL  max_allowed_packet=67108864;
SET GLOBAL  net_buffer_length=10000;   
 
注意:该值设置过小将导致单个记录超过限制后写入数据库失败,且后续记录写入也将失败 
原文地址:https://www.cnblogs.com/zhutouying/p/6134724.html