mysqlvariables在退出后重置

会计/时间跟踪软件(客户和利润X)的Web界面需要打开连接到其MySQL数据库。 目前,Web界面并没有定期使用,而且这个时间已经过去了。 当有人想要使用networking界面时,在这一点上被打破,直到我重新启动程序。

我试图在OSX Snow Leopard服务器上将MySQL中的max_timeout设置为5天,但是它会一直重置为默认的8小时。 你可以从下面的代码中看到,我设置了全局variables和会话variables,但是在退出并重新login到mysql之后,会话variables被重置。 我不会假装成为SQL的专家,所以我可能只是愚蠢的。 这是在OSX SL服务器上,虽然我不知道它是否特定于这个平台。

mysql> set wait_timeout=432000; Query OK, 0 rows affected (0.00 sec) mysql> set global wait_timeout=432000; Query OK, 0 rows affected (0.00 sec) mysql> SHOW VARIABLES LIKE 'wait%'; +---------------+--------+ | Variable_name | Value | +---------------+--------+ | wait_timeout | 432000 | +---------------+--------+ 1 row in set (0.00 sec) mysql> SHOW GLOBAL VARIABLES LIKE 'wait%'; +---------------+--------+ | Variable_name | Value | +---------------+--------+ | wait_timeout | 432000 | +---------------+--------+ 1 row in set (0.00 sec) mysql> exit Bye osxserver:~ admin$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.92-log Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SHOW VARIABLES LIKE 'wait%'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | wait_timeout | 28800 | +---------------+-------+ 1 row in set (0.00 sec) mysql> SHOW GLOBAL VARIABLES LIKE 'wait%'; +---------------+--------+ | Variable_name | Value | +---------------+--------+ | wait_timeout | 432000 | +---------------+--------+ 1 row in set (0.00 sec) 

我在[mysqld]下的/etc/my.cnf中设置了wait_timeout,虽然我不确定这是设置会话variables还是全局variables

 server:~ admin$ grep wait_timeout /etc/my.cnf wait_timeout = 432000 

你可以看看这个关于mysql的bug报告。

http://bugs.mysql.com/bug.php?id=33123

它突出了几种检查超时设置的方法。

但是,从链接中删除的主要原因是wait_timeout可以被用于连接到数据库服务器的连接string覆盖。

在交互式客户端的情况下,它将会话wait_timeout设置为28,800。 有效覆盖你的configuration设置。 所以这不能被用来作为一个“testing”,看看它是否工作。

只要C&PX不在连接string中压倒这个值,那么你应该没问题。

您可以尝试使用init_connect触发器来设置每个连接上的值

这里的例子http://shinguz.blogspot.com/2010/02/logging-users-to-mysql-error-log.html

您的客户端的.my.cnf可能会有一个wait_timeout,当您重新login时重新将超时初始化为8小时,从而有效地覆盖了新会话的全局值。 另外,由于您的示例使用了mysql shell,因此可能会将您的会话wait_timeout设置为interactive_wait_timeout。 该值可以来自全局设置,或者再次来自客户端的.my.cnf。