zoukankan      html  css  js  c++  java
  • MySQL报错Packet for query is too large问题解决

    今天用java写了批量插入运行时,报错:

    Error updating database.  Cause: com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (1,399,241 > 1,048,576). You can change this value on the server by setting the 'max_allowed_packet' variable.

    出现问题的原因:批量插入数据量过大

    MySQL根据配置文件会限制Server接受的数据包大小。有时候插入、更新或查询时数据包的大小,会受 max_allowed_packet 参数限制,导致操作失败。

    mysql> show VARIABLES like '%max_allowed_packet%';
    +--------------------------+------------+
    | Variable_name | Value |
    +--------------------------+------------+
    | max_allowed_packet | 1048576 |
    | slave_max_allowed_packet | 1073741824 |
    +--------------------------+------------+

    说明:

      1*1024*1024 = 1048576 =1M

    解决办法

    修改mysql配置文件 windows下 my.ini

    在[mysqld]下添加

    max_allowed_packet = 524288000

    说明:

      500*1024*1024 =524288000=500M

    修改完成之后要重启mysql

    mysql> show VARIABLES like '%max_allowed_packet%';
    +--------------------------+------------+
    | Variable_name | Value |
    +--------------------------+------------+
    | max_allowed_packet | 524288000 |
    | slave_max_allowed_packet | 1073741824 |
    +--------------------------+------------+

      

  • 相关阅读:
    uva 1584.Circular Sequence
    成为Java顶尖程序员 ,看这11本书就够了
    java 线程同步 原理 sleep和wait区别
    xargs -r
    java
    事故分析
    各大互联网公司架构演进之路汇总
    char 汉字
    nginx优化之request_time 和upstream_response_time差别
    学习进度05
  • 原文地址:https://www.cnblogs.com/baby123/p/11288166.html
Copyright © 2011-2022 走看看