• -------------------------------------------------------------
  • ====================================

MySql Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’ 解决方法

大数据库 dewbay 5年前 (2019-10-12) 1901次浏览 已收录 0个评论 扫描二维码

环境: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_connections%’;

    ② 修改 max_connection_errors 的数量为 1000: set global max_connections = 1000;

③ 查看是否修改成功:show variables like ‘%max_connections%’;

2、使用mysqladmin flush-hosts 命令清理一下 hosts 文件(不知道mysqladmin在哪个目录下可以使用命令查找:whereis mysqladmin);

① 在查找到的目录下使用命令修改:/usr/bin/mysqladmin flush-hosts -h192.168.1.1 -P3308 -uroot -prootpwd;

备注:

其中端口号,用户名,密码都可以根据需要来添加和修改;

配置有 master/slave 主从数据库的要把主库和从库都修改一遍的(我就吃了这个亏明明很容易的几条命令结果折腾了大半天);

第二步也可以在数据库中进行,命令如下:flush hosts;


露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:MySql Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’ 解决方法
喜欢 (0)
[]
分享 (0)
关于作者:
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址