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

2024-04-16 0 162
目录
  • ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many
    • 报错
    • 解决
  • 数据库报错create connection SQLException,……errorCode 1129, state HY000
    • 原因
    • 解决办法
  • 总结

    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 1mysql> 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

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

    报错:

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

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

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

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

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

    永久性修改:vim my.cnf

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

    修改完配置文件,重启mysql

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

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

    总结

    以上为个人经验,希望能给大家一个参考,也希望大家多多支持悠久资源网。

    收藏 (0) 打赏

    感谢您的支持,我会继续努力的!

    打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
    点赞 (0)

    悠久资源 Mysql 解决ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many问题 https://www.u-9.cn/database/mysql/185382.html

    常见问题

    相关文章

    发表评论
    暂无评论
    官方客服团队

    为您解决烦忧 - 24小时在线 专业服务