解决mysqladmin flush-hosts

发布时间 2023-08-10 17:04:04作者: 金虹巴巴

1、提高允许的max_connect_errors数量(治标不治本)
a.命令行修改
  修改max_connection_errors的数量为1000
  mysql -h 123.57.78.101 -P 3306 -uroot -p123456
  set global max_connect_errors=1000;
  show variables like ‘%max_connect_errors%’;

b.配置文件修改
  登陆进入Mysql数据库查看max_connect_errors
  mysql -h 你的ip -P 你的端口 -uroot -p123456
  show variables like ‘%max_connect_errors%’;
  mysql-connection-error-mysqladmin-flush-hosts-solutions-00
  max_connect_errors 默认是10 或 100,修改方法如下:
   vim /etc/my.cnf
  添加一行
  max_connect_errors=1000
  重启MySQL,修改才会生效!
  /etc/init.d/mysqld restart
  mysql-connection-error-mysqladmin-flush-hosts-solutions-01


2、使用mysqladmin flush-hosts 命令清理一下hosts文件
  如果不知道mysqladmin在哪个目录下,可以使用命令查找:which mysqladmin

a.命令修改flush-hosts
  /usr/bin/mysqladmin flush-hosts -h 123.57.78.101 -P 3306 -uroot -p123456
  备注:其中服务器IP地址,端口号,用户名,密码,上面参数都可以根据需要来添加和修改;
  配置有master/slave主从数据库的要把主库和从库都修改一遍的
  第二步,在数据库中进行,执行命令如下:
  flush hosts;

b.重启数据库
  /etc/init.d/mysqld restart