今天将项目部署到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. UVA - 11082 Matrix Decompressing (最大流,技巧)

    很经典的网络流模型,行编号和列编号分别看成一个点,行和列和分别看出容量,一个点(x,y)看出是一条边,边的容量下界是1,所以先减去1,之后在加上就好了. 建图的时候注意分配好编号,解从残留网络中的边找 ...

  2. 一、新手必会Python基础

    博客内容: 1.基础语法 2.运算符 3.流程控制 4.列表.元组.字典.集合 5.字符串 6.文件操作 一.基础语法 1.标识符 命名规则: 以字母.下划线开头 其他部分由字母.数字或下划线组成 不 ...

  3. xampp中php手动升级

    http://windows.php.net/download/           //要下载的 里面有dll文件 http://www.php.net/downloads.php VC9 x86 ...

  4. javase(10)_多线程基础

    一.排队等待 1.下面的这个简单的 Java 程序完成四项不相关的任务.这样的程序有单个控制线程,控制在这四个任务之间线性地移动.此外,因为所需的资源 ― 打印机.磁盘.数据库和显示屏 -- 由于硬件 ...

  5. javaEE(14)_文件上传下载

    一.文件上传概述 1.实现web开发中的文件上传功能,需完成如下二步操作: •在web页面中添加上传输入项•在servlet中读取上传文件的数据,并保存到本地硬盘中. 2.如何在web页面中添加上传输 ...

  6. 将 PROTOCOL 的方法声明为 MUTATING

    将 PROTOCOL 的方法声明为 MUTATING 由 王巍 (@ONEVCAT) 发布于 2014/08/17 Swift 的 protocol 不仅可以被 class 类型实现,也适用于 str ...

  7. 【模板】任意模数NTT

    题目描述: luogu 题解: 用$fft$水过(什么$ntt$我不知道). 众所周知,$fft$精度低,$ntt$处理范围小. 所以就有了任意模数ntt神奇$fft$! 意思是这样的.比如我要算$F ...

  8. Linux 中 MySQL 授权远程连接

    说明:当别的机子(IP )通过客户端的方式在没有授权的情况下是无法连接 MySQL 数据库的,如果需要远程连接 Linux 系统上的 MySQL 时,必须为其 IP 和具体用户进行授权.一般 root ...

  9. 条款40:明智而审慎地使用多重继承(use multiple inheritance judiciously)

    NOTE: 1.多重继承比单一继承复杂.它可能导致新的歧义性,以及对virtual继承的需要. 2.virtual 继承会增加大小 速度 初始化(及赋值)复杂度等等成本.如果virtual base ...

  10. Django REST framework 五种增删改查方法

    Django-DRF-视图的演变   版本一(基于类视图APIView类) views.py: APIView是继承的Django View视图的. 1 from .serializers impor ...