Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’ 解决方法
环境:centos7,mysql8
错误:Host is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’
原因:
同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;
解决方法:
1、提高max_connection_errors数量:
(1)、临时解决(重启后恢复):修改max_connection_errors的数量为1000: set global max_connect_errors=1000;
查看是否修改成功:SHOW GLOBAL VARIABLES LIKE ‘%max_connect_errors%’;
(1)、永久修复:修改my.ini中max_connection_errors=1000。重启服务永久生效
2、使用mysqladmin flush-hosts 命令清理一下hosts文件(临时应急处理);
mysqladmin flush-hosts -h iphost -P port -u root -prootpasswd;
备注:
也可以mysql -uroot -prootpasswd 在数据库中执行命令:flush hosts;