MySQL查詢超時的問題處理方法
有時我們會遇到MySQL查詢超時的問題,下面就為您介紹MySQL查詢超時的問題處理方法,供您參考,希望能夠?qū)δ兴鶈⒌稀?/P>
mysql>show variables like '%timeout';
打印結(jié)果如下:
+----------------------------+-------+
| 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()設(shè)置CLIENT_INTERACTIVE選項后起作用,并被賦值為wait_timeout;
mysql>set wait_timeout = 10; 對當(dāng)前交互鏈接有效;
mysql>set interactive_timeout = 10; 對后續(xù)起的交互鏈接有效;
該超時時間單位是秒,從變量從上次SQL執(zhí)行后算起;當(dāng)前空閑若超過該時間,則也會被強制斷開。
nteractive_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.
譯解:客戶端和服務(wù)器交互的空閑超時時間。該系統(tǒng)變量僅當(dāng)客戶端連接服務(wù)器時設(shè)置了“MYSQL_CLIENT_INTERACTIVE”標(biāo)志才生效,例如:
/啟用MYSQL_CLIENT_INTERACTIVE模式,連接數(shù)據(jù)庫服務(wù)器
$link = mysql_connect($host, $user, $pwd, false, MYSQL_CLIENT_INTERACTIVE);
以上就是MySQL查詢超時的問題處理方法的介紹。
【編輯推薦】