【MySQL】Host is blocked because of many connection errors

【问题描述 】:
应用服务器那边发现连不到数据库,查看日志发现报错:

  1. selectSQL get mysql connection failed, err:Error: ER_HOST_IS_BLOCKED Host 'xx.xx.xx.xx' is blocked because of many connection errors ……

【解决方案 】:
读了日志发现该错误与connection errors有关,查了一下 max_connect_errors参数:
  1. SELECT @@global.max_connect_errors;
  2. +-----------------------------+
  3. | @@global.max_connect_errors |
  4. +-----------------------------+
  5. | 10                          |
  6. +-----------------------------+
  7. 1 row in 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中执行:
  1. mysql> FLUSH HOSTS;
执行指令
  1. mysqladmin flush-hosts
即可通过【 flushing the host cache 】来解锁这个“host


然后调大连接错误数,避免再次发生此类问题:(为Dynamic Variable)
  1. mysql> SET @@global.max_connect_errors=100000;

最后添加/修改my.cnf,增加:

  1. max_connect_errors = 100000

后来继续 查了一下5.5的文档发现,其默认值就为10,而 5.6.6以后的版本中,该默认值已经调到了100。

参考文档:
MySQL 5.5 Reference Manual / Chapter 5 MySQL Server Administration / 5.1.1 Server Option and Variable Reference


作者微信公众号(持续更新)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29773961/viewspace-2079581/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29773961/viewspace-2079581/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值