前幾天部署了一個項目在伺服器上,隔幾天就會出現404 ????
org.springframework.dao.RecoverableDataAccessException:
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
後來查詢部落格,發現是資料庫的問題 :
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5CN5EWOjdDOyMjYihzYhNjZlZjN5kDOmJWOkhDZ1gTN38CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
上圖表示,mysql8小時沒有連接配接的時候,就會自動斷開.....
檢視mysql5的手冊,發現對wait_timeout的最大值分别是24天/365天(windows/linux)。以windows為例,假設我們要将其設為21天,我們隻要修改mysql5的配置檔案“my.ini”(mysql5 installation dir),增加一行:wait_timeout=1814400
需要重新啟動mysql5。
inux系統配置檔案:/etc/my.cnf
查詢 my.cnf的位置 find / -name my.cnf
在[mysqld]後面加上如下兩句話
wait_timeout=691200
interactive_timeout=691200
重新開機下mysql
顯示如下内容
停止 MySQL: [确定]
啟動 MySQL: [确定]
在查詢
show global variables like 'wait_timeout';
看看變了沒