MySQL資料庫報錯java.sql.SQLException: null, message from server: “Host ‘192.168.XXX’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’”
問題:
IDEA啟動專案時控制臺報錯:java.sql.SQLException: null, message from server: “Host ‘192.168.XX.XX’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’”
環境:
在Linux上Docker運行MySQL(5.7)
原因:
同一個ip在短時間內產生太多(超過mysql資料庫max_connection_errors的最大值)中斷的資料庫連接而導致的阻塞;
解決方式:
-
方式一:(自己是通過這種方式解決的)
重啟mysql服務即可 即docker restart mysql -
方式二:
通過命令列進行mysql控制臺 即flush hosts -
方式三:
| 修改默認的max_connect_errors連接數(mysql 5.6以上默認是100) |
|---|
| 顯示默認連接數:show variables like ‘%max_connect_errors%’ |
|---|
| 修改連接數為500:set global max_connect_errors = 500; (基本上同一IP不可能超過500) |
|---|
| flush privileges |
|---|
| service mysql restart |
|---|
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/289713.html
標籤:其他
