## [mysql數據庫1129錯誤](https://www.cnblogs.com/shuilangyizu/p/10113920.html)
```
最近簡單的辦法:
數據庫工具執行`flush hosts;`
```
錯誤: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;
大多數的百度結果都是這樣,但是對于我的數據庫連接還是不行,經多次驗證,發現需要加上主機地址,即執行下面命令:
~~~
mysqladmin flush-hosts -h 127.0.0.1 -uroot -p
~~~
127.0.0.1如果不行可以將其修改為當前主機的ip地址。