解决ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?of?many问题

 更新时间:2024年04月01日 09:11:40   作者:亦是花  
这篇文章主要介绍了解决ERROR?1129?(HY000):?Host?‘xxx‘?is?blocked?because?of?many问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many

报错

ERROR 1129 (HY000): Host '27.227.134.197' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

解决

mysql> flush hosts;

如果以上报如下错,则使用下面步骤:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-hosts' at line 1
mysql> show variables like "max_connection_errors";

1.首先使用 root 登录 mysql -u root -p 或者

mysql -uroot -h39.97.49.66 -p

2.提高允许的max_connection_errors数量:

① 进入Mysql数据库查看

max_connection_errors: show variables like "max_connection_errors";

② 修改max_connection_errors的数量为1000:

set global max_connect_errors = 1000;

③ 修改 max_connections 的数量为1000 :

set global max_connections = 1000;

3.最后使用 mysql> flush-hosts; 命令清理一下hosts文件;

数据库报错create connection SQLException,......errorCode 1129, state HY000

报错:

com.alibaba.druid.pool.DruidDataSource   : create connection SQLException, url: jdbc:mysql://mysql:3306/config?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai, errorCode 1129, state HY000

错误:

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_connect_errors%';

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

③ 查看是否修改成功:show variables like '%max_connection_errors%';

永久性修改:vim  my.cnf

修改完配置文件,重启mysql

最后再次查看服务,发现报错没有了,恢复正常。

持续了一段时间又报出了这种错误,排查这台服务器上的服务,最后发现是因为有一个服务没有创建数据库用户,所以导致这个服务一直连接数据库报错导致的。

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持程序员之家。

相关文章

最新评论

?


http://www.vxiaotou.com