mysql設置連接等待時間(wait_timeout)


Linux下 mysql修改連接超時
 
1,首先進入mysql,查看 wait_timeout、interactive_timeout這個值是否為默認的8小時(即 28800) 
[root@server110 ~]# mysql -u root -p 
Enter password: 
輸密碼進入 
執行如下命令 
show variables like '%timeout%'; 
+----------------------------+-------+ 
| Variable_name              | Value | 
+----------------------------+-------+ 
| connect_timeout            | 10    | 
| delayed_insert_timeout     | 300   | 
| innodb_lock_wait_timeout   | 50    | 
| innodb_rollback_on_timeout | OFF   | 
| interactive_timeout        | 28800 | 
| net_read_timeout           | 30    | 
| net_write_timeout          | 60    | 
| slave_net_timeout          | 3600  | 
| table_lock_wait_timeout    | 50    | 
| wait_timeout               | 28800 | 
+----------------------------+-------+ 
如下表所示,說明連接超時時間使用的是默認的8小時 
修改之 
2.在mysql 5以上的版本需要修改my.cnf這個文件,這個文件的位置在 
/etc/my.cnf 
在[mysqld]后面加上如下兩句話 
wait_timeout=388000 
interactive_timeout=388000 
3.下面重啟下mysql 
service mysqld restart 
顯示如下內容 
停止 MySQL:                                               [確定] 
啟動 MySQL:                                               [確定] 
現在你可以在用1的方法,查看下這兩個參數的值 
+----------------------------+--------+ 
| Variable_name              | Value  | 
+----------------------------+--------+ 
| connect_timeout            | 10     | 
| delayed_insert_timeout     | 300    | 
| innodb_lock_wait_timeout   | 50     | 
| innodb_rollback_on_timeout | OFF    | 
| interactive_timeout        | 388000 | 
| net_read_timeout           | 30     | 
| net_write_timeout          | 60     | 
| slave_net_timeout          | 3600   | 
| table_lock_wait_timeout    | 50     | 
| wait_timeout               | 388000 | 
+----------------------------+--------+ 
OK,修改好了 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM