Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql 'wait_timeout' Global Variable vs Variable

Tags:

mysql

I am trying to reproduce a connection timeout error by temporarily reducing the "wait_timeout" to 60 seconds instead of the default 28800 seconds.

I added wait_timeout=60 to the my.ini file and restarted MySql. Unfortunately, I am still not able to reproduce the error condition (unless i want to wait 28800 seconds).

The queries below seem to indicate the "wait_timeout" is set to 60 at the global variable level but still set at 28800 seconds for the regular variable (is that the same as the session variable?).

How can I correct this? How is the setting in the my.ini getting overwritten?

Thanks for any advice as I am still a bit of a MySql admin noob. :)

I'm running MySql 5.5.10 on Windows XP.

mysql> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show global variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 60    |
+---------------+-------+
1 row in set (0.00 sec)
like image 320
Justin Avatar asked Apr 30 '11 00:04

Justin


1 Answers

From MySQL documentation: wait_timeout:

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.

You should also lower interactive_timeout global variable in your ini file.

Also note that:

This timeout applies only to TCP/IP and Unix socket file connections, not to connections made using named pipes, or shared memory.

(As Vladislav pointed the above note should be disregarded, as this bug has been fixed and the timeout applies to connections with named pipes or shared memory as well, but apparently the docs have not been updated.)

like image 85
ypercubeᵀᴹ Avatar answered Sep 25 '22 18:09

ypercubeᵀᴹ