---
title: "MySql Host is blocked because of many connection errors; unblock with 'mysqladmi"
author: "lihaiming"
date: "2016-07-25T11:11:20Z"
tags: []
categories: ["数据库"]
slug: "mysql-host-is-blocked-because-of-many-connection-errors-unblock-with-mysqladmi"
draft: false
lastmod: "2016-07-25T11:11:20Z"
id: 2313231
url: "https://lihaiming.iteye.com/blog/2313231"
---

[MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法](http://www.cnblogs.com/susuyu/archive/2013/05/28/3104249.html)

**环境：**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;**

 

**本文来源于：[http://www.cnblogs.com/susuyu/archive/2013/05/28/3104249.html](http://www.cnblogs.com/susuyu/archive/2013/05/28/3104249.html)**

 

**自己操作步骤：**

**1.远程连接数据库所在主机      ssh root@192.168.7.188**  
**2.输入密码     qw365qb666**  
**3.进入目录     cd /usr/bin**  
**4.连接数据库  mysql -uroot -p111111**  
**5.执行命令      flush hosts;**  
**或者/usr/bin/mysqladmin flush-hosts -h192.168.7.188 -P3306 -uroot -p111111**