Fork me on GitHub

Packet for query is too large(mysql写入数据过大)

mysql数据库

 

开发小程序时遇到这样的错误

 

{"code":-1,"message":"\n### Error querying database.  Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1032 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.\n### The error may exist in file
[/root/apache-tomcat-8.5.24/myapp/api/WEB-INF/classes/com/starball/dao/mapper/SubjectDao.xml]\n###
The error may involve defaultParameterMap\n### The error occurred while setting parameters\n### SQL: select ms.subject_id as subject_id, ms.topic_title as topic_title,
ms.sponsor_userid as sponsor_userid, ms.sponsor_phone_number as sponsor_phone_number, date_format( ms.begin_time, '%m月-%d日') as begin_date , date_format( ms.begin_time, '%H:%i') as begintime , date_format( ms.end_time, '%m月-%d日') as end_date , date_format( ms.end_time, '%H:%i') as endtime , ms.location as location, ms.longitude as longitude, ms.latitude as latitude,
ms.max_paricipants_number as max_paricipants_number, ms.actual_participants_number as actual_participants_number, ms.personal_expense as personal_expense,
ms.reminder_minutes as reminder_minutes, ms.is_repeat as is_repeat, date_format(ms.create_time,'%Y-%m-%d %T') as create_time, ms.note as note, ms.activity_status as activity_status, ms.payment_method as payment_method from miniapp_subject_members msm left join miniapp_subject ms on msm.subject_id=ms.subject_id where msm.user_id=? and msm.member_status>0
order by ms.create_time desc\n### Cause:
com.mysql.jdbc.PacketTooBigException:
Packet for query is too large (1032 > 1024).
You can change this value on the server by setting the max_allowed_packet' variable.\n; SQL []; Packet for query is too large (1032 > 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 (1032 > 1024).
You can change this value on the server by setting the max_allowed_packet' variable.","data":null}

 

 

经查询 需要设置mysql 参数,由于我的mysql是安装在docker里,所以找到路径添加'max_allow_packet=16M

进入目录 

root@6dbd3dacff00:/etc/mysql/mysql.conf.d#

 

找到mysqld.cnf文件编辑,在  symbolic-links=0后添加如下 参数

max_allowed_packet = 16M

 

 

如果该参数总会不定期的被自动还原, 首先请检查内存是否足够,开启general log 查看是否被攻击。

posted @ 2018-01-21 17:48  低调的神  阅读(551)  评论(0编辑  收藏  举报