MySQL连接超时相关的两个参数interactive_timeout和wait_timeout的区别及解释

本篇内容主要讲解“MySQL连接超时相关的两个参数interactive_timeout和wait_timeout的区别及解释”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MysqL连接超时相关的两个参数interactive_timeout和wait_timeout的区别及解释”吧!

先看看官方文档对于这两个参数的定义

interactive_timeout
认是28800,单位秒,即8个小时
The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INteraCTIVE option to MysqL_real_connect(). See also wait_timeout.


wait_timeout
认同样是28800s
The number of seconds the server waits for activity on a noninteractive connection before closing it.
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.


interactive_timeout针对交互式连接,wait_timeout针对非交互式连接。所谓的交互式连接,即在MysqL_real_connect()函数中使用了CLIENT_INteraCTIVE选项。
说得直白一点,通过MysqL客户端连接数据库是交互式连接,通过jdbc连接数据库是非交互式连接。 


interactive_timeout:交互式连接超时时间(MysqL工具、MysqLdump等)
wait_timeout:非交互式连接超时时间,认的连接MysqL api程序,jdbc连接数据库
 在连接启动的时候,根据连接的类型,来确认会话变量wait_timeout的值是继承于全局变量wait_timeout,还是interactive_timeout。


如何设置和查看:
MysqL> set global interactive_timeout=1800;
Query OK, 0 rows affected (0.00 sec)


MysqL> set global wait_timeout=1800;
Query OK, 0 rows affected (0.00 sec)


MysqL> show global variables like 'interactive_timeout';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| interactive_timeout | 1800  |
+---------------------+-------+
1 row in set (0.00 sec)


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

到此,相信大家对“MysqL连接超时相关的两个参数interactive_timeout和wait_timeout的区别及解释”有了更深的了解,不妨来实际操作一番吧!这里是编程之家网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

相关文章

这篇文章主要介绍“hive和mysql的区别是什么”,在日常操作中...
这篇“MySQL数据库如何改名”文章的知识点大部分人都不太理解...
这篇文章主要介绍“mysql版本查询命令是什么”的相关知识,小...
本篇内容介绍了“mysql怎么修改字段的内容”的有关知识,在实...
这篇文章主要讲解了“mysql怎么删除unique约束”,文中的讲解...
今天小编给大家分享一下mysql怎么查询不为空的字段的相关知识...