数据库
首页 > 数据库> > Mysql批量插入数据量过大报错:Packet for query is too large (8472393 > 4194304). You can change this value on the

Mysql批量插入数据量过大报错:Packet for query is too large (8472393 > 4194304). You can change this value on the

作者:互联网

Mysql批量插入数据量过大报错:Packet for query is too large (8472393 > 4194304). You can change this value on the

mysql max_allowed_packet查询和修改


max_allowed_packet 如果不设置,默认值在不同的 MySQL 版本表现不同,有的版本默认1M,有的版本默认4M。


1. 查看当前配置:

mysql> show variables like 'max_allowed_packet';
    
mysql> select @@max_allowed_packet;


修改方法1(修改MySQL配置文件)

# Linux
vim /etc/my.cnf
[mysqld]
max_allowed_packet = 1024M

# Windows则修改my.ini文件

注意:修改配置文件以后,需要重启mysql服务才能生效。


修改方法2(命令行临时修改):

# 修复为1024M
mysql> set global max_allowed_packet = 1024 * 1024 * 1024;

标签:1024,4194304,max,mysql,packet,修改,报错,value,allowed
来源: https://blog.csdn.net/ayunnuo/article/details/122327915