mysql5.7报错Packet for query is too large

通过第三方接口拉取数据后,解析存储到mysql、es、fastdfs中,但存储到mysql过程中部分数据会报错,错误信息如下:

Packet for query is too large (41649082>1048576). 
You can change this value on the server by setting the max_allowed_packet’ variable.

查询资料后,max_allowed_packet指mysql服务器端和客户端在一次传送数据包的过程当中最大允许的数据包大小。也就是不能超过设定的数据包的最大值,否则报错。
解放方案:调整max_allowed_packet参数,按需调整
方法一(永久生效)
修改 my.ini 加上 max_allowed_packet = 67108864
67108864=64M;

修改完成之后要重启mysql服务,如果通过命令行修改就不用重启mysql服务。

方法二(不需要重启mysql)
命令修改,设置为100M
mysql> set global max_allowed_packet = 10010241024;
查看mysql的max_allowed_packet大小,运行
show VARIABLES like ‘%max_allowed_packet%’;

org.springframework.dao.TransientDataAccessResourceException: ### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (155,396,072 > 67,108,864). You can change this value on the server by setting the 'max_allowed_packet' variable. ### The error may exist in class path resource [mapper/SupplierBaseBackupMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: INSERT INTO sup_backup (id, applicant, applicant_date, applicant_remark, applicant_id, new_supplier_data_info, old_supplier_data_info, status, supplier_id, supplier_name, supplier_code, company_id, company_name, company_code, enterprise_id, effective_date, create_date, creator, creator_name, update_date, modifier, modifier_name) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ### Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (155,396,072 > 67,108,864). You can change this value on the server by setting the 'max_allowed_packet' variable. ; Packet for query is too large (155,396,072 > 67,108,864). You can change this value on the server by setting the 'max_allowed_packet' variable.; nested exception is com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (155,396,072 > 67,108,864). You can change this value on the server by setting the 'max_allowed_packet' variable.这个max_allowed_packet要在哪里修改
最新发布
10-30
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值