解決MYSQL 8小時串連問題

來源:互聯網
上載者:User

並不知道該connection已經失效,如果這時有 Client請求connection,將該失效的Connection提供給Client,將會造成上面的異常。 

8 hours in idle status.
;
set global wait_timeout= ;

mysql> show variables like '%timeout%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| connect_timeout          | 5     |
| delayed_insert_timeout  | 300   |
| innodb_lock_wait_timeout | 50    |
| interactive_timeout      | 28800 |
| net_read_timeout         | 30    |
| net_write_timeout        | 60    |
| slave_net_timeout        | 3600 |
| wait_timeout             | 28800 |
+--------------------------+-------+         
同一時間,這兩個參數只有一個起作用。到底是哪個參數起作用,和使用者串連時指定的串連參數相關,預設情況下是使用wait_timeout。我建議是將這兩個參數都修改,以免引起不必要的麻煩。

將這2個參數設定為1年(60*60*24*365=31536000)

set interactive_timeout=31536000;
set wait_timeout=31536000;

MySQL times out idle connections after 8 hours(28,800 seconds)
MySQL idle timeout


 




相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.