mysql的wait_timeout和interactive_timeout
###wait_timeout interactive_timeout####
wait_timeout :對於非互動連線,mysql在關閉它之前的等待時間
這個值的初始化根據連線客戶端的連線方式不同:有兩種方式:全域性的wait_timeout或者是全域性的interactive_timeout
interactive_timeout:對於互動連線,mysql在關閉它之前的等待時間
測試:
root:3406:(none)>show variables like '%timeout%';
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 21 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| thread_pool_idle_timeout | 60 |
| wait_timeout | 21 |
+-----------------------------+----------+
14 rows in set (0.00 sec)
root:3406:(none)>show global variables like '%timeout%';
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 21 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| thread_pool_idle_timeout | 60 |
| wait_timeout | 14 |
+-----------------------------+----------+
14 rows in set (0.00 sec)
root:3406:(none)>show global variables like '%timeout%';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 4
Current database: *** NONE ***
+-----------------------------+----------+
| Variable_name | Value |
+-----------------------------+----------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| have_statement_timeout | YES |
| innodb_flush_log_at_timeout | 1 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 21 |
| lock_wait_timeout | 31536000 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| rpl_stop_slave_timeout | 31536000 |
| slave_net_timeout | 60 |
| thread_pool_idle_timeout | 60 |
| wait_timeout | 14 |
+-----------------------------+----------+
14 rows in set (0.00 sec)
上面是測試互動輸入的方式,
wait_timeout =14
interactive_timeout=21
可以看到session級別的wait_timeout的初始化使用了interactive_timeout
當超過了21s後,再執行命令連線已經被幹掉了
綜上:
針對client其實真正生效的是session級別的wait_timeout,空閒連線(互動和非互動),
超過其session級別的wait_timeout時間就會被回收掉:
虛擬碼:
if (client_connection is interactive) then
session wait_timeout= global interactive_timeout
else if(client_connection is noninteractive ) then
session wait_timeout= global wait_timeout
end if
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20625855/viewspace-1717890/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【Mysql】MySQL中interactive_timeout和wait_timeout的區別MySqlAI
- MySQL之wait_timeout和interactive_timeout引數MySqlAI
- MySQL:引數wait_timeout和interactive_timeout以及空閒超時的實現MySqlAI
- MySQL中wait_timeout的坑MySqlAI
- mysql interactive_timeout 設定不當一例MySql
- Python 操作 mysql 資料庫,wait_timeout 後報什麼錯誤PythonMySql資料庫AI
- Springboot 連線池wait_timeout超時設定Spring BootAI
- Mysql的redolog和binlogMySql
- mysql的mysql.event和information_schema.eventsMySqlORM
- MySQL 的索引和事務MySql索引
- Oracle和MySQL的區別OracleMySql
- MYSQL和SQL的區別MySql
- mysql中“ ‘ “和 “ ` “的區別MySql
- MySQL和Oracle的區別MySqlOracle
- mysql中!=和is not的區別MySql
- MySQL 裡的 find_in_set () 和 in () 和 likeMySql
- 安裝mysql和mysql workbenchMySql
- MySQL中的redo log和checkpointMySql
- MySQL中的事務和MVCCMySqlMVC
- mysql索引的使用和優化MySql索引優化
- MySQL binlog和redo的組提交MySql
- mysql中\G和\g的作用MySql
- 【MySQL】MySQL備份和恢復MySql
- mysql的安裝和簡單的操作MySql
- MySQL5.7和MySQL8.0的區別是什麼?MySql
- mysql安裝教程8.0.26 安裝mysql的步驟和方法MySql
- mysql alter modify 和 change的區別MySql
- MySql和簡單的sql語句MySql
- MySQL的DDL和DML操作語法MySql
- MySQL中datetime和timestamp的區別MySql
- MySQL的下載、安裝和配置MySql
- MySQL中的redo log和undo logMySql
- MySQL之Where和Having的區別MySql
- MySQL 的啟動和連線方式MySql
- 談談mysql和redis的區別MySqlRedis
- Mysql 中 MyISAM 和 InnoDB 的區別MySql
- SQLserver-MySQL的區別和用法ServerMySql
- MySQL的共享鎖和獨佔鎖MySql
- Oracle 和 mysql的9點區別OracleMySql