Change connect_timeout in MySQL

connect_timeout – the number of seconds that the mysql server waits for the connection package before terminating the connection.

Connect to MySQL and see the current value:

mysql -u USER -p
show variables like "connect_timeout";
quit;

The value of connect_timeout can be specified in the file /etc/mysql/my.cnf, for example:

[mysqld]
connect_timeout=10

In real time, you can change by executing the SQL query (after restarting MySQL it will be reset to the standard or specified in the configuration file):

SET GLOBAL connect_timeout=10;

The standard value is 10, the minimum value is 2, the maximum is 31536000.

Leave a comment

Leave a Reply