Packet for query is too large

foreword

max_allowed_packet
mysql根据max_allowed_packet限制server接收数据包的大小, 数据量超过这个限制时会导致写入或更新失败.
View current restrictions
show VARIABLES like '%max_allowed_packet%';

Revise

以下提供两种修改方式
1. Modify the configuration file
# 查看配置文件路径
mysql --help | grep my.cnf

# 修改
vim /etc/my.cnf

在[mysqld]段增加或修改以下内容:
max_allowed_packet = 5M

# 重启mysql
service mysql restart
2. Command line modification
# 登录mysql
mysql -u root -p

# 运行指令
set global max_allowed_packet = 5*1024*1024
# 如果上条命令无效:
# set @@max_allowed_packet=5*1024*1024

# 重启mysql
service mysql restart   # ubuntu
service mysqld restart  # centos

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324983366&siteId=291194637