Tuesday, August 21, 2012

How to change timeout for mysql persistent connections to keep alive

How to change timeout for mysql persistent connections to keep alive

mysql> SHOW VARIABLES LIKE '%_timeout';

Result shows 28800 (i.e. 8 hours), which is the default wait_timout.

mysql> SET SESSION wait_timeout = 86400; // 1 day. Maximum is 24.8 Days.
mysql> SET SESSION interactive_timeout = 86400; // 1 day. Maximum is 24.8 Days.

mysql> SHOW PROCESSLIST


wait_timeout is the amount of seconds during inactivity that MySQL will wait before it will close a connection on a non-interactive connection.

interactive_timeout is the same, but for interactive sessions (mysql shell)

No comments: