Why mysql max_allowed_packet reset to 1m automatically

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

I set

SET GLOBAL max_allowed_packet=16777216;  

and also

[mysqld] max_allowed_packet = 16M 

I checked the max_allowed_packet through below command

SHOW VARIABLES LIKE 'max_allowed_packet'; 

and the value is = 16777216

But after some days max_allowed_packet automatically reset to 1M.

回答1:

i am pretty sure that your are hacked. i had the same problem for months. i opened general_log and finally found some codes:

   connect root@someipaddress on    Query select 0x4D5A900..........(verylong)    Query select sys_exe('cmd /c  c:/windows/nbvqc4.vbs')    .........    set global max_allowed_packet 1024    ........ 

suggestion: change your root password.



回答2:

MySQL has both GLOBAL variables and SESSION variables, as well as the my.cnf.

GLOBAL variables are initialised on startup from my.cnf, and many variables are taken from the GLOBAL value at connection time and copied into the SESSION. If you change the GLOBAL value, the SESSION keeps it's own value -- but any new sessions will take the new GLOBAL default.

It seems that you did the right thing in terms of setting the GLOBAL variable and updating my.cnf, but in your example you ran "SHOW VARIABLES" which returns the SESSION value. So it is possible you were not checking the correct value in that case. I would recommend for all future checks that you check both the global and session values to help get an idea of what is changing when.

SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'; SHOW SESSION VARIABLES LIKE 'max_allowed_packet';

For the value to change itself later, the following explanations are possible

(1) You are re-using a session that still has the old value (2) Another connection has run SET GLOBAL max_allowed_packet, it is possible even that some uncourteous application or script is doing this (3) The server was restarted, and the my.cnf change is not being applied as expected -- perhaps the file is in the wrong path, or the setting exists more than once in the configuration file. I would check the current Uptime in SHOW GLOBAL STATUS to understand if the server was restarted

I cannot think of any other reasons this would occur. I did check to see if the client negotiates the server-side value when you pass --max_allowed_packet but that does not seem to be the case.



回答3:

Yes, someone hack the system.I changed the root password and everything working fine.



回答4:

By default value of max_allowed_packet is 1M in MySQL. I believe size of your "max_allowed_packet" is exceed its upper limit. So, when you check "SHOW VARIABLES LIKE 'max_allowed_packet';" its showing some negative value.

Additionally,

You have two values of max_allowed_packet in MySQL :

one on the client side : [mysql] section, [mysqldump], [client] and more. one on the server side : [mysqld] section.



回答5:

Try setting 'Super' privilege of all users to 'N', except 1 admin user. This prevents users from changing max_allowed_packet.



回答6:

We just ran into this issue and the root cause is we were hacked. Some 3rd party was running a script that was changing the value down.

Tip for those trying to figure out if a hack is a root cause for them - temporarily change your MySQL logging to include all queries. That's how we ended up finding the issue.



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