【問題描述】:
應用
服務器那邊發(fā)現(xiàn)連不到數(shù)據(jù)庫,查看日志發(fā)現(xiàn)報錯:
-
selectSQL get MySQL connection failed, err:Error: ER_HOST_IS_BLOCKED Host 'xx.xx.xx.xx' is blocked because of many connection errors ……
【解決方案】:
讀了日志發(fā)現(xiàn)該錯誤與connection errors有關,查了一下max_connect_errors參數(shù):
-
SELECT @@global.max_connect_errors;
-
+-----------------------------+
-
| @@global.max_connect_errors|
-
+-----------------------------+
-
| 10 |
-
+-----------------------------+
-
1 rowin set (0.00 sec)
原來是10,果然太小了。
查了一下5.5文檔,官方給出了解決方案:
However, once a host is blocked, flushing the host cache is the only way to unblock it.在mysql中執(zhí)行:
或執(zhí)行指令:
即可通過【flushing the host cache】來解鎖這個“host”
然后調(diào)大連接錯誤數(shù),避免再次發(fā)生此類問題:(為Dynamic Variable)
-
mysql> SET @@global.max_connect_errors=100000;
最后添加/修改my.cnf,增加:
-
max_connect_errors = 100000
后來繼續(xù)查了一下5.5的文檔發(fā)現(xiàn),其默認值就為10,而5.6.6以后的版本中,該默認值已經(jīng)調(diào)到了100。
參考文檔:
MySQL 5.5 Reference Manual / Chapter 5 MySQL Server Administration / 5.1.1 Server Option and Variable Reference
彌勒ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
作者微信公眾號(持續(xù)更新)
當前文章:【MySQL】Hostisblockedbecauseofmanyconnectionerrors
瀏覽路徑:
http://m.jiaotiyi.com/article/jpcejp.html