SET GLOBAL max_allowed_packet doesn't work

我的梦境 提交于 2019-11-30 00:04:42

Hmmmm.. You have hit this NOT-A-BUG it seems. :)

If you change a global system variable, the value is remembered and used for new connections until the server restarts. (To make a global system variable setting permanent, you should set it in an option file.) The change is visible to any client that accesses that global variable. However, the change affects the corresponding session variable only for clients that connect after the change. The global variable change does not affect the session variable for any client that is currently connected (not even that of the client that issues the SET GLOBAL statement).

Refer this too. Read Shane Bester explanation.

You should change from the my.ini/my.cnf file and restart the server for the max_allowed_packet setting to take effect.

After running

set global max_allowed_packet=1000000000;

you have to restart mysql before

SHOW VARIABLES LIKE 'max_allowed_packet'

will show the new value.

I have this issue when restarting mysql through the MAC OSX system preferences and the value hadn't changed. So by logging into mysql via console

mysql -u root -p

changing it and then restarting mySql seemed to work. Might have been a OS X quirk though.

BeardedGeek

Just a quick way to see the variable for anybody who comes across this. To get the value back you need to run

SHOW VARIABLES LIKE 'max_allowed_packet'

For those with a MariaDb configuration the problem could be that the max_allowed_packet variable is overwritten by a configuration file called later.

In my case I tried to import a database and the server answered me: ERROR 2006 (HY000) at line 736: MySQL server has gone away

I discovered that the file:

/etc/mysql/mariadb.conf.d/50-server.cnf

is called later

/etc/mysql/conf.d/mysql.cnf

I tried continuously changing in the "mysql.cnf" file but the value was overwritten in "50-server.cnf".

So the solution is to enter the file

/etc/mysql/mariadb.conf.d/50-server.cnf

and instead of "max_allowed_packet = 16M" put the desired value as an example "max_allowed_packet = 64M"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!