Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to customize MySQL variables (e.g. max_allowed_packet
, read_buffer_size
or wait_timeout
) on a Plesk server?
Answer
Note: Custom values must not exceed the limits defined by MySQL. For example, the highest value for max_allowed_packet
is 1073741824 bytes (1024M) for wait_timeout
- 31536000 seconds.
- Connect to the Plesk server via SSH.
-
Open the my.cnf file in a text editor. In this example, we are using the vi editor:
- on CentOS/RHEL-based distributions:
# vi /etc/my.cnf
- on Debian/Ubuntu-based distributions:
# vi /etc/mysql/my.cnf
- on CentOS/RHEL-based distributions:
-
Add your custom variables under the
[mysqld]
section. If the variable is also applicable to[client]
and[mysqldump]
sections, add it there too.In this example, we are adding
max_allowed_packet
andwait_timeout
directives:CONFIG_TEXT: [mysqld]
wait_timeout = 31536000
max_allowed_packet=512M
...
[client]
max_allowed_packet=512M
...
[mysqldump]
max_allowed_packet=512M -
Save the changes and close the file.
-
Restart the MySQL service:
# service mysql restart || service mariadb restart || service mysqld restart
- Connect to Plesk server via RDP.
- Open the file
%plesk_dir%Databases\MySQL\my.ini
in a text editor. -
Add your custom variables under the
[mysqld]
section. If the variable is also applicable to[client]
and[mysqldump]
sections, add it there too.In this example, we are adding
max_allowed_packet
andwait_timeout
:CONFIG_TEXT: [mysqld]
wait_timeout = 31536000
max_allowed_packet=512M
...
[client]
max_allowed_packet=512M
...
[mysqldump]
max_allowed_packet=512M -
Save the changes and close the file.
-
Restart the MySQL service via Windows Services or Plesk Services Monitor.
Comments
12 comments
I increased max_allowed_packet editing the right my.cnf file, and I confirmed using phpMyAdmin that the new value is applying.
Periodically, max_allowed_packet reset itself to 1024, even lower than MySQL default (that is 4M), crashing the majority of websites relying on MySQL.
@Marco Marsala
Hello!
Such behavior is caused by MySQL Bug.
See also MySQL forum topic regarding this issue.
@Ivan Postnikov
This is classified as “not a bug”. The forum topic says that 3rd party software is running a query to reset the value to 1024.
My code never run such query. The only 3rd party running on the server is Plesk panel.
Maybe this is a Plesk issue?
@Marco Marsala
Hello!
In this case, I would suggest submitting a ticket for Plesk Technical Support, as more detailed investigation is required.
Should Screenshot for Windows Plesk be updated so thick would be on "SQL Server" group or "MySQL56" service and not on "Plesk SQL Server"?
@Almir The article has been updated, thank you!
Thank you
I use centos 7 with plesk
For CentOS
Command: vi /etc/my.cnf
This code is not visible.
[mysqld]
wait_timeout = 31536000
max_allowed_packet=32M
....
[mysqldump]
max_allowed_packet=32M
You need add this line
Hello Edwynn Flores Martínez
Yes, correct. It is needed to add these parameters in the /etc/my.cnf configuration file.
There is no definable place to put these lines. I can't just add the block as it corrupts my plesk database after restart.
not explained, my.cnf is very diferent to this
Rafael Dominguez Rodriguez You can put the mentioned parameters to any place within [mysqld] and [mysqldump] sections: in the beginning, or in the end - it should work
Please sign in to leave a comment.