環境:linux,mysql5.5.21
錯誤:Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
原因:
同一個ip在短時間内産生太多(超過mysql資料庫max_connection_errors的最大值)中斷的資料庫連接配接而導緻的阻塞;
解決方法:
1、提高允許的max_connection_errors數量(治标不治本):
① 進入Mysql資料庫檢視max_connection_errors: show variables like '%max_connection_errors%';
② 修改max_connection_errors的數量為1000: set global max_connect_errors = 1000;
③ 檢視是否修改成功:show variables like '%max_connection_errors%';
2、使用mysqladmin flush-hosts 指令清理一下hosts檔案(不知道mysqladmin在哪個目錄下可以使用指令查找:whereis mysqladmin);
① 在查找到的目錄下使用指令修改:/usr/bin/mysqladmin flush-hosts -h192.168.1.1 -P3308 -uroot -prootpwd;
備注:
其中端口号,使用者名,密碼都可以根據需要來添加和修改;
配置有master/slave主從資料庫的要把主庫和從庫都修改一遍的(我就吃了這個虧明明很容易的幾條指令結果折騰了大半天);
第二步也可以在資料庫中進行,指令如下:flush hosts;
<b></b>
<b>本文轉自黃聰部落格園部落格,原文連結:http://www.cnblogs.com/huangcong/p/5072915.html,如需轉載請自行聯系原作者</b>