MySql-Host 'xxxxxxx' is blocked because of many connection errors; unblock with 'mysqlad

1,问题:

  在本地连接数据库,可以成功启动项目;

  但是,在sit环境下,却不能成功启动

  报以下异常:

  Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

  Caused by: java.sql.SQLException: null,  message from server: "Host '118.89.226.156' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

2,原因:

  同一个IP地址在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞。

3,方案:

  1),紧急方案

  清理一下hosts文件

  命令:flush hosts;

  2),一劳永逸

  提高允许的max_connection_errors数量:

    ① 进入Mysql数据库查看max_connection_errors: 

    命令:show variables like '%max_connection_errors%';

    ② 修改max_connection_errors的数量为1000: 

    命令:set global max_connect_errors = 1000;

    ③ 查看是否修改成功:

    命令:show variables like '%max_connection_errors%';

  或者

    直接在配置文件中修改my.ini中修改

    max_connect_errors=1000

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值