【MySQL】Host is blocked because of many connection errors
【问题描述】:
应用服务器那边发现连不到数据库,查看日志发现报错:
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参数:
SELECT @@global.max_connect_errors;
+-----------------------------+
| @@global.max_connect_errors |
+-----------------------------+
| 10 |
+-----------------------------+
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中执行:
mysql>FLUSH HOSTS; 或执行指令:
mysqladmin flush-hosts 即可通过【flushing the host cache】来解锁这个“host”
然后调大连接错误数,避免再次发生此类问题:(为Dynamic Variable)
mysql> SET @@global.max_connect_errors=100000;
最后添加/修改my.cnf,增加:
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
应用服务器那边发现连不到数据库,查看日志发现报错:
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参数:
SELECT @@global.max_connect_errors;
+-----------------------------+
| @@global.max_connect_errors |
+-----------------------------+
| 10 |
+-----------------------------+
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中执行:
mysql>FLUSH HOSTS; 或执行指令:
mysqladmin flush-hosts 即可通过【flushing the host cache】来解锁这个“host”
然后调大连接错误数,避免再次发生此类问题:(为Dynamic Variable)
mysql> SET @@global.max_connect_errors=100000;
最后添加/修改my.cnf,增加:
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
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。