码迷,mamicode.com
首页 > 其他好文 > 详细

max_allowed_packet

时间:2015-04-20 16:17:20      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

程序运行错误提示:

org.springframework.dao.TransientDataAccessResourceException: 
### Error updating database.  Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1482 > 1024). You can change this value on the server by setting the max_allowed_packet‘ variable.
### The error may involve com.rlglsys.mapper.IRlgl010106Mapper.updateUnit-Inline
### The error occurred while setting parameters
### SQL: UPDATE m_tb04_unit SET                            unit_own             =?,    earnings_nature      =?  ,    unit_manage_scale    =? ,    unit_manage_scale_tow=?,    unit_manage_scale_nm=?,    unit_economic_type   =?,    unit_nature          =?,    unit_nature_tow      =?,    unit_level           =?  ,    industry_plan        =?,    agency_level         =?,    agency_level_tow     =? ,    agency_level_three    =?  ,    unit_scale           =?,    license_no           =?,    establishment_num    =?,    organization_no      =? ,    organization_code    =? ,    unit_address         =?,    offical_scope        =?,    unit_pro             =? ,       hospital_grade       =? ,                hospital_grade_tow   =? ,                   unit_img             =? ,               area_id              =? ,           unit_lower           =?  ,           system_sort          =? ,                   industry_divide      =? ,               system_sort_two      =? ,           industry_divide_two  =?  ,          agency_plan =?  ,    ex_key = ?,      del_kbn = ?,                           expend_01 = ?,           expend_02 = ?,           expend_03 = ?,           expend_04 = ?,           expend_05 = ?,           login_user_id = ?,               login_date = ?,                      update_user_id = ?,             update_date = ?                               WHERE unit_no = ?;
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1482 > 1024). You can change this value on the server by setting the max_allowed_packet‘ variable.
; SQL []; Packet for query is too large (1482 > 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 (1482 > 1024). You can change this value on the server by setting the max_allowed_packet‘ variable.

 

解决方案:

在linux命令栏中:输入:whereis mysql

可以显示mysql的安装目录: /usr/share/mysql

1.找到 【my-default.cnf】文件:把max_allowed_packet = 20M  的值调大些即可。

2.在etc/my.cnf文件中,找到max_allowed_packet设置,默认是1MB,我们可以修改为10MB或者20MB,随意。然后重启网站环境之后再导入数据库命令执行,就可以完全的执行导入数据库。

重新启动mysql:service mysql restart

通过 ps -el | grep mysqld   查看mysql的启动情况。

技术分享

通过此语句查看mysql中max_allowed_packet的大小:

show VARIABLES like ‘%max_allowed_packet%‘;

max_allowed_packet

标签:

原文地址:http://www.cnblogs.com/hanxf/p/4441522.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!