MySql'wait_timeout'全局变量vs变量 [英] MySql 'wait_timeout' Global Variable vs Variable

查看:151
本文介绍了MySql'wait_timeout'全局变量vs变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过将"wait_timeout"暂时减少到60秒而不是默认的28800秒来重现连接超时错误.

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

我在my.ini文件中添加了wait_timeout = 60并重新启动了MySql.不幸的是,我仍然无法重现错误情况(除非我想等待28800秒).

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).

以下查询似乎表明在全局变量级别上,"wait_timeout"设置为60,但对于常规变量,它仍设置为28800秒(与会话变量相同吗?).

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?).

我该如何纠正? my.ini中的设置如何被覆盖?

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

谢谢您的建议,因为我还是MySql管理员的菜鸟. :)

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

我正在Windows XP上运行MySql 5.5.10.

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)

推荐答案

来自MySQL文档:

From MySQL documentation: wait_timeout:

在线程启动时,会话wait_timeout值从全局变量初始化 wait_timeout 值或全局 interactive_timeout 值,具体取决于 客户端类型(由CLIENT_INTERACTIVE connect选项定义为 mysql_real_connect()).另请参见interactive_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.

您还应该在ini文件中降低interactive_timeout全局变量.

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

还要注意:

Also note that:

此超时仅适用于TCP/IP和Unix套接字文件连接, 而不是使用命名管道或共享内存建立的连接.

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

(如Vladislav指出的,应忽略上面的注释,因为 此错误具有已修复 ,并且超时也适用于具有命名管道或共享内存的连接,但是显然文档尚未更新.)

(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.)

这篇关于MySql'wait_timeout'全局变量vs变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆