今天将项目部署到linux服务器的时候莫名其妙的报一些错误,可是在本地啥错没有,通过实时查看tomcat 的日志之后发现报错是:  

实时查看日志:

1、先切换到:cd usr/local/tomcat5/logs

2、tail -f catalina.out

3、这样运行时就可以实时查看运行日志了

发现错误:

rg.springframework.dao.TransientDataAccessResourceException:
### Error querying database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1233 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
### The error may exist in cn/xm/exam/mapper/employee/out/custom/UnitCustomMapper.xml
### The error may involve cn.xm.exam.mapper.employee.out.custom.UnitCustomMapper.getHaulunitByCondition-Inline
### The error occurred while setting parameters
### SQL: SELECT haulunit.unitId, haulunit.unitBigId, haulunit.bigId, (select group_concat(projectname) from project where projectid in (select projectId from haulunitproject where bigId =haulunit.bigId and unitId= haulunit.unitId)) as projectNames, haulunit.manager, haulunit.managerPhone, haulunit.secure, haulunit.securePhone, @b:= (IFNULL((SELECT SUM(minusNum) FROM breakrules, haulemployeeout WHERE breakrules.BigEmployeeoutId = haulemployeeout.BigEmployeeoutId AND haulemployeeout.unitid = haulunit.unitId and breakTime LIKE CONCAT(Year(CurDate()),'%') ),0)) AS unitMinisMum, haulinfo.bigName, haulinfo.bigStatus, haulinfo.bigCreateDate, unit.name, unit.address, unit.contact, unit.phone, @a:= (SELECT COUNT(BigEmployeeoutId) FROM haulemployeeout WHERE haulemployeeout.bigId = haulunit.bigId AND haulemployeeout.unitId = haulunit.unitId and trainstatus='2') AS personNum, TRUNCATE(IFNULL(@b/@a,0),3) AS jiaquan FROM haulunit, haulinfo, unit WHERE haulunit.bigId=haulinfo.bigId AND haulunit.unitId=unit.unitId and haulunit.bigId = ? ORDER BY jiaquan desc limit ?,?
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1233 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
; SQL []; Packet for query is too large (1233 > 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 (1233 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:107)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)

-----------------解决办法:(通过查看mysql全局变量发现原因是mysql限制了最大更新大小)----------------------

mysql max_allowed_packet 设置过小导致记录写入失败

mysql根据配置文件会限制server接受的数据包大小。

有时候大的插入和更新会受max_allowed_packet 参数限制,导致写入或者更新失败。

查看目前配置

show VARIABLES like '%max_allowed_packet%';

显示的结果为:

+--------------------+---------+

| Variable_name      | Value   |

+--------------------+---------+

| max_allowed_packet | 1048576 |

+--------------------+---------+

以上说明目前的配置是:1M

修改方法

1、修改配置文件

可以编辑my.cnf来修改(windows下my.ini),在[mysqld]段或者mysql的server配置段进行修改。

max_allowed_packet = 20M

如果找不到my.cnf可以通过

mysql --help | grep my.cnf

去寻找my.cnf文件。

linux下该文件在/etc/下。

2、在mysql命令行中修改

在mysql 命令行中运行

set global max_allowed_packet = 2*1024*1024*10

然后退出命令行,重启mysql服务,再进入。

show VARIABLES like '%max_allowed_packet%';

查看下max_allowed_packet是否编辑成功

 
 注意:该值设置过小将导致单个记录超过限制后写入数据库失败,且后续记录写入也将失败。
 
 
三、如何重启Linux的mysql

1、使用 service 启动:service mysqld restart

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld restart

mysql报错Packet for query is too large (12238 > 1024). You can change this value的更多相关文章

  1. MySQL报错Packet for query is too large问题解决

    今天用java写了批量插入运行时,报错: Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigExcep ...

  2. Linux服务器上日志报com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1783 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.

    在做查询数据库操作时,报了以上错误,还有out of memery heap hacp ,原因是MySQL的max_allowed_packet设置过小引起的,我一开始设置的是1M,后来改为了20M ...

  3. mysql异常:Packet for query is too large (10240 > 1024). You can change this value

    出现这个问题的原因是:mysql的配置文件中 max_allowed_packet 设置过小,mysql根据配置文件会限制server接受的数据包大小. 还有人会说我操作的数据量明显没有超过这个值为啥 ...

  4. com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1680 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.

    这个错误是由于mysql的一个系统参数max_allowed_packet设置的值过小引起的 解决这个错误的方法就是修改这个参数的值, linux系统中我们在etc目录下找到my.cnf这个文件,打开 ...

  5. Packet for query is too large (12238 > 1024). You can change this value

    MySQL max_allowed_packet 设置过小导致记录写入失败 mysql根据配置文件会限制server接受的数据包大小. 有时候大的插入和更新会受max_allowed_packet 参 ...

  6. com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024)

    ### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024). You ...

  7. nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1044 > 1024

    HTTP Status 500 - type Exception report message description The server encountered an internal error ...

  8. 问题: Packet for query is too large (1786 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.

    错误描述: 今天在手机端查看之前上线的项目时,突然报了下面的错误.再之后用电脑登陆,其他设备登陆都一直报这个错误. 错误信息: ### Error querying database. Cause: ...

  9. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (16944839 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.

    今天发现task微服务的error日志报如下错误: Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large ...

随机推荐

  1. LinuxShell(脚本如何编译问题)

    想学shell的同学请记住: 如果你写好脚本后不给脚本执行权限那也是不行的: 添加执行权限: chmod +x 脚本名.sh 在Linux shell中有一个脚本编译命令: bash -v 脚本名.s ...

  2. rpn网络结构再分析

    这是rpn网络train阶段的网络结构图 rpn_conv1之前的网络是特征提取层,也是和fast rcnn共享的层.rpn_conv1是一层1*1的卷积,这一层是单独为rpn网络多提取一层特征,这一 ...

  3. Codeforces Round #277.5 (Div. 2)-C. Given Length and Sum of Digits...

    http://codeforces.com/problemset/problem/489/C C. Given Length and Sum of Digits... time limit per t ...

  4. JS面试题--使用for循环打印1-10,每个数字出现的间隔约500ms

    又来刷面试题啦,哈哈. 要求:使用for循环打印1-10,每个数字出现的间隔约500ms. 分析:考察点--闭包,块级作用域 方式一.使用闭包+立即执行函数,自己当时的思路也是这样想的,但是,结果却没 ...

  5. 【思维题】AGC013C - Ants on a Circle

    妙妙技巧题 题目描述 题目大意 一个圆环上有n只蚂蚁,它们会按照顺时针或者逆时针行走.如果有蚂蚁相遇它们就会掉头(不一定在整数时间掉转).问最后每只蚂蚁的位置. 题目分析 以前在luogu上做过一道类 ...

  6. 【dp】淘宝的推荐系统

    可能最近做二分和DFS做傻了? 小明刚刚入职淘宝,老大给他交代了一个简单的任务,实现一个简易的商品推荐系统. 这个商品推荐系统的需求如下: 一共有 n 件商品可以被推荐,他们的编号分别为 1 到 n. ...

  7. ajax实现上传图片保存到后台并读取

    上传图片有两种方式: 1.fileReader  可以把图片解析成base64码的格式,简单粗暴 2.canvas  可以重新绘制一张图片,可以先把获取得到的图片的blob放进canvas里面,再生成 ...

  8. 浅谈Session与Cookie的关系

    一.概念理解: 首先cookie是服务端识别客户的唯一标识的依据,客户在访问网站时候,服务端为了记住这个客户,会在服务端按照它的规则制作一个cookie数据,会将这个cookie数据保留在服务端一段时 ...

  9. Python面向对象(类之间的关系)(三)

    类与类之间的关系 在我们的世界中事物和事物之间总会有一些联系. 在面向对象中. 类和类之间也可以产生相关的关系 1. 依赖关系 执行某个动作的时候. 需要xxx来帮助你完成这个操作. 此时的关系是最轻 ...

  10. Java-在一个包装器对象中包装一个原始类型

    使用基本类型的包装对象,好处可以为空且可以序列化 package com.tj; public class MyClass2 { public static void main(String[] ar ...