应用日志提示错误:
create connection error, url: jdbc:mysql://10.45.236.235:3306/db_wang?useUnicode=true&characterEncoding=UTF-8, errorCode 1129, state HY000java.sql.SQLException: null, message from server: "Host '10.30.174.183' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"java
缘由:mysql
同一个ip在短期内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库链接而致使的阻塞;sql
解决方法:数据库
一、提升容许的max_connect_errors数量(这种方法不完全,后期还可能致使异常出现):url
进入Mysql数据库查看max_connect_errors: show variables like 'max_connect_errors';spa
修改max_connect_errors的数量为1000: set global max_connect_errors = 1000;日志
查看是否修改为功:show variables like 'max_connect_errors';code
二、使用mysqladmin flush-hosts 命令清理一下hosts文件server
whereis mysqladmin查找mysqladmin的路径ip
使用命令修改:
/usr/bin/mysqladmin flush-hosts -h192.168.1.121 -uroot -p
备注:
配置有master/slave主从数据库的要把主库和从库都修改一遍
第二步也能够在数据库中进行,命令以下:flush hosts; mysql> flush hosts;