解决方法 MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
MySQL错误代码:
MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
原因分析:
同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;
解决方法:
(解决方案有两个,一个是提高数据库的最大连接数量,另一个则是清理host文件)
方法一:
提高允许的max_connection_errors数量(治标不治本)
1、进入Mysql数据库查看max_connection_errors:
show variables like '%max_connection_errors%';
2、修改max_connection_errors的数量为1000:
set global max_connect_errors = 1000;
3、查看是否成功:
show variables like '%max_connection_errors%';
方法二:
使用mysqladmin flush-hosts 命令清理一下hosts文件,(不知道mysqladmin在哪个目录下可以使用命令查找:whereis mysqladmin);
在查找到的目录下使用命令修改:
mysqladmin flush-hosts -hhostip -uroot -pmysqlpwd;
注:
1)其中端口号,用户名,密码都可以根据需要来添加和修改;,
2)配置有master/slave主从数据库的要把主库和从库都修改一遍的(我就吃了这个亏明明很容易的几条命令结果折腾了大半天);
3)第二步也可以在数据库中进行,命令如下:
flush hosts;
注意:阿里云服务器PK腾讯云服务器,很便宜!
①阿里云:2核4G服务器188元/年,4核8G服务器346元/年,8c16g等(价格很低很低)
②腾讯云:2核4G云服务器8M带宽70元一年(有高配)
③华为云:华为云服务器60元一年起(查看更多配置报价)
发表评论