解决ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many问题
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
最后再次查看服务,发现报错没有了,恢复正常。
持续了一段时间又报出了这种错误,排查这台服务器上的服务,最后发现是因为有一个服务没有创建数据库用户,所以导致这个服务一直连接数据库报错导致的。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
- 解决springboot项目启动报错Error creating bean with name dataSourceScriptDatabaseInitializer问题
- SpringBoot启动报错Whitelabel Error Page: This application has no explicit mapping for的解决方法
- MySQL报错:Starting MySQL ERROR! Couldn‘t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
- 解决修复报错Error in render:TypeError:Cannot read properties of undefined(reading ‘ipconfig‘)问题
相关文章
使用Kubernetes集群环境部署MySQL数据库的实战记录
这篇文章主要介绍了使用Kubernetes集群环境部署MySQL数据库,主要包括编写 mysql.yaml文件,执行如下命令创建,通过相关命令查看创建结果,对Kubernetes部署MySQL数据库的过程感兴趣的朋友一起看看吧2022-05-05如何使用myisamchk和mysqlcheck工具快速修复损坏的MySQL数据库文件
有时候数据库突然就坏了很郁闷,用mysqlcheck.exe可以修复受损数据库2020-01-01使用mysql的disctinct group by查询不重复记录
非常不错的方法,用mysql的group by解决不重复记录的问题,看来我需要学习的地方太多了2008-08-08
最新评论