MySQL 什么是mysql默认的wait_timeout和interactive_timeout

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21076306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:48:42  来源:igfitidea点击:

What is the default mysql wait_timeout and interactive_timeout

mysqlsqltimeout

提问by user2693017

I changed these timeouts globally with:

我通过以下方式全局更改了这些超时:

SET GLOBAL wait_timeout=30; SET GLOBAL interactive_timeout=30

and noticed that I have another application running which got problems with these "low" timeouts. So I would like to undo this and only apply it to the specific database.

并注意到我正在运行另一个应用程序,该应用程序遇到了这些“低”超时的问题。所以我想撤消这个,只将它应用于特定的数据库。

采纳答案by Ilia Rostovtsev

Referring to the MySQL Manualthe default values for wait_timeoutand for interactive_timeoutare - 28800.

参考MySQL 手册wait_timeout和 for的默认值interactive_timeout是 - 28800

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

在线程启动时,会话wait_timeout 值从全局wait_timeout值或全局interactive_timeout值初始化 ,这取决于客户端的类型(由mysql_real_connect() 的CLIENT_INTERACTIVE 连接选项定义)。另见interactive_timeout。

回答by gus

I have the same problem in 5.5.43. I was having the "has gone away" error message for some long queries beyond about 2 minutes. So I tried these 3:

我在5.5.43. 对于一些超过大约 2 分钟的长时间查询,我收到了“已消失”错误消息。所以我尝试了这三个:

(1) SHOW VARIABLES LIKE 'wait_%';

(1) SHOW VARIABLES LIKE 'wait_%';

(2) SHOW global VARIABLES LIKE 'wait_%';and

(2)SHOW global VARIABLES LIKE 'wait_%';

(3) SHOW session VARIABLES LIKE 'wait_%';.

(3) SHOW session VARIABLES LIKE 'wait_%';.

All showed wait_timeout to be 28800. Then I added wait_timeout = 31536000to /etc/my.cnf. Then my long query was able to complete. And from the 3 ways of showing variables above, only (2) the one with "global" showed a change from 28800 to 31536000. The other 2 were unaffected. Since my long-query was definitely less than 10 minutes long, does this mean that the unit of time used here was millisecondsrather than seconds?

都显示 wait_timeout 为28800。然后我添加wait_timeout = 31536000/etc/my.cnf. 然后我的长查询就可以完成了。而从上面的3种显示变量的方式来看,只有(2)有“global”的那个显示了从28800到31536000的变化,其他2种不受影响。由于我的长查询肯定少于 10 分钟,这是否意味着这里使用的时间单位是毫秒而不是