【前言】 大家好,我是新人,今天來分享架服一開始沒人玩的話, 大概會遇到一個問題如以下的錯誤代碼:
- [Saving] Error saving character data: com.mysql.jdbc.exceptions.jdbc4.Communicat
- ionsException: The last packet successfully received from the server was61144 se
- conds ago.The last packet sent successfully to the server was 61144 seconds ago,
- which is longer than the server configured value of 'wait_timeout'. You should
- consider either expiring and/or testing connection validity before use in your
- application, increasing the server configured values for client timeouts, or usi
- ng the Connector/J connection property 'autoReconnect=true' to avoid this proble
- m.
- [Saving] Error rolling back: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientCo
- nnectionException: Can't call rollback when autocommit=true
- [Saving] Error going back to autocommit mode: com.mysql.jdbc.exceptions.jdbc4.Co
- mmunicationsException: The last packet successfully received from the server was
- 61144 seconds ago.The last packet sent successfully to the server was 61144 seco
- nds ago, which is longer than the server configured value of 'wait_timeout'. Yo
- u should consider either expiring and/or testing connection validity before use
- in your application, increasing the server configured values for client timeouts
- , or using the Connector/J connection property 'autoReconnect=true' to avoid thi
- s problem.
目前測試是太久沒有登入遊戲,遊戲也沒人在玩的時候, 會遇到這個問題,以下提供有效的暫時解決方法
「步驟一」 點一下WAMP → MySQL → MySQL控制台
「步驟二」 輸入你的MySQL密碼 ( 沒有設置密碼直接按Enter進入即可 )
「步驟三」 輸入 "show variables like '%timeout%'; " 會看到有兩個數值為28800的參數,分別是 : - interactive_timeout
- wait_timeout
28800是秒數,大家可以換算一下28800/60/60=8小時 意味著8小時若是沒有人對資料庫進行操作就會自動關閉, 一般可重啟伺服器就可以解決了,但不想重啟伺服器的人, 可以使用以下方法。
「步驟四」 MySQL控制台輸入密碼後再輸入下面指令 - set wait_timeout=2147483;
- set interactive_timeout=2147483;
「步驟五」 在這之後你再輸入" show variables like '%timeout%'; " 檢查一下就會發現你的"interactive_timeout"和"wait_timeout" 這兩個值被改為2147483(大約是24天,目前測試為最大值)
「步驟六」 這樣你的伺服器就可以24天不用重開囉^^
【後記】 補充方法
mysql目錄下,複製my-default.ini,命名為my.ini 編輯my.ini,在[mysqld]下方新增兩行 interactive_timeout=31536000 wait_timeout=31536000 重啟mysql,完成。
確認方法: 開啟cmd,cd到mysql\bin 接著mysql\bin> mysql -u root -p 會叫你輸入密碼(Enter password) 接著mysql> show variables like '%timeout%'; 確認數值是否為給定值31536000。
【作者】:yasc5223 【整理】:AICL集團
|