广告
返回顶部
首页 > 资讯 > 数据库 >MySQL连接超时相关的两个参数interactive_timeout和wait_timeout的区别及解释
  • 152
分享到

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

2024-04-02 19:04:59 152人浏览 薄情痞子
摘要

本篇内容主要讲解“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的区别及解释”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

您可能感兴趣的文档:

--结束END--

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

本文链接: https://www.lsjlt.com/news/59640.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作