MySQL查詢超時問題是什麼原因呢?應該如何解決呢?下面就為您詳細介紹MySQL查詢超時問題的解決方法,希望可以幫助到您。
- mysql>show variables like '%timeout';
打印結果如下:
- +----------------------------+-------+
- | Variable_name | Value |
- +----------------------------+-------+
- | connect_timeout | 5 |
- | delayed_insert_timeout | 300 |
- | interactive_timeout | 28800 |
- | net_read_timeout | 30 |
- | net_write_timeout | 60 |
- | slave_net_timeout | 3600 |
- | wait_timeout | 28800 |
- +----------------------------+-------+
interactive_timeout 需在mysql_connect()設置CLIENT_INTERACTIVE選項後起作用,並被賦值為wait_timeout;
mysql>set wait_timeout = 10; 對當前交互鏈接有效;
mysql>set interactive_timeout = 10; 對後續起的交互鏈接有效;
該超時時間單位是秒,從變量從上次SQL執行後算起;當前空閒若超過該時間,則也會被強制斷開。
interactive_timeout(常用)
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.
譯解:客戶端和服務器交互的空閒超時時間。該系統變量僅當客戶端連接服務器時設置了“MYSQL_CLIENT_INTERACTIVE”標志才生效,例如:
- //啟用MYSQL_CLIENT_INTERACTIVE模式,連接數據庫服務器
- $link = mysql_connect($host, $user, $pwd, false, MYSQL_CLIENT_INTERACTIVE);
教您如何調整MySQL查詢緩沖
MySQL查詢優化器的工作原理
深度解析MySQL查詢緩存機制
常用MySQL命令行工具介紹
MySQL無重復查詢的實現