Change wait_timeout and interactive_timeout in MySQL

wait_timeout – The number of seconds that the server waits for activity in a non-interactive connection before closing it.
At the time of connection, wait_timeout is taken from the global value wait_timeout or interactive_timeout depending on the client type (as defined by the CLIENT_INTERACTIVE connect option for mysql_real_connect ())

Connect to MySQL and see the current value:

mysql -u USER -p
show variables like "wait_timeout";
show variables like "interactive_timeout";
quit;

By default, the values wait_timeout and interactive_timeout are 28800 seconds = 8 hours.
You can set minimum 1, maximum – 31536000, maximum (for Windows) – 2147483.

You can change the value of wait_timeout by executing the SQL query, for example:

set global wait_timeout = 28800;
set global interactive_timeout = 28800;

That the set value has not been reset, it needs to be specified in the file /etc/mysql/my.cnf, in the mysqld block:

[mysqld]
wait_timeout = 28800
interactive_timeout = 28800

Leave a comment

Leave a Reply