【MySQL】Host is blocked because of many connection errors

发布时间:2020-08-10 20:39:43 作者:神谕丶
来源:ITPUB博客 阅读:193
【问题描述】:
应用服务器那边发现连不到数据库,查看日志发现报错:

  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


作者微信公众号(持续更新)
【MySQL】Host is blocked because of many connection errors
推荐阅读:
  1. MySQL监控平台的构建方法
  2. mysql连接报错的原因和解决方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

host because many

上一篇:LeetCode 27.Remove Element 数组元素删除

下一篇:prettier怎么设置

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》