MySQL 应用程序报错 Host is blocked because of many connection errors

在应用程序中时不时出现错误:Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

一、 原因

  同一个ip在短时间内产生太多中断的数据库连接(超过mysql数据库max_connection_errors设置)而导致的阻塞。

二、 解决方法

1. 提高允许的max_connection_errors数量

查看max_connection_errors,默认为10

show variables like '%max_connection_errors%';

主从库修改max_connection_errors的数量为1000(立即生效)

 set global max_connect_errors = 1000;

主从库在my.cnf中[mysqld]下添加(重启后不失效)

max_connect_errors = 1000

2. 重置错误记录数

mysql> flush-hosts;

猜你喜欢

转载自blog.csdn.net/Hehuyi_In/article/details/111595351