Mysql报错 mysql server has gone away, How to change max_allowed_packet size, max_allowed_packet in mySQL

 

查看 max_allowed_packet 默认值:

show variables like '%max_allowed_packet%

默认一般是 16M (16777216)

 

修改默认值:

max_allowed_packet=500M

 

方法如下:

1)打开终端

2)ssh root @ YOURIP

3)输入root密码

4)vi /etc/mysql/my.cnf

# /etc/my.cnf
[mysqld]
max_allowed_packet=16M

5)在[MYSQLD]部分下添加行:max_allowed_pa​​cket = 256M(显然可以根据需要调整大小)。错误地把它放在文件的底部,所以它不起作用。

Mysql报错 mysql server has gone away, How to change max_allowed_packet size, max_allowed_packet in mySQL
Mysql报错 mysql server has gone away, How to change max_allowed_packet size, max_allowed_packet in mySQL

6):wq(保存并退出文件)

7)服务mysqld重启 sudo service mysql restart

8)您可以在phpmyadmin上检查变量部分的更改

 

 

 

本文: Mysql报错 mysql server has gone away, How to change max_allowed_packet size, max_allowed_packet in mySQL

Leave a Reply