前言

今天同事跟我反应,mysql无法直接连接。

我用mysql workbench去连接,发现此报错:

Host 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.

 

原因

同个ip连接mysql时,短期内出现的连接和断裂次数过大而造成的阻塞。

 

解决

三种方法:

  1. 在mysql中重置最大错误连接数

    mysql> flush hosts;   #默认的max_connection_errors=10,可适当调大
    Query OK, 0 rows affected (0.00 sec)
    

    如果mysql有主从或者MGR集群,则主备机器都要执行。

  2. 在配置文件中添加此项,然后重启mysql服务:

    [mysqld]
    max_connect_errors = 1000
    
  3. 在数据库中添加max_connection_errors

    mysql> show variables like '%max_connection_errors%';
    Empty set (0.01 sec)
    
    mysql> set global max_connect_errors = 1000;
    Query OK, 0 rows affected (0.00 sec)
    

相关文章:

  • 2022-02-18
  • 2021-12-03
  • 2021-08-29
  • 2021-09-13
  • 2022-12-23
  • 2022-03-01
  • 2021-06-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2021-11-27
  • 2021-05-01
  • 2021-09-27
  • 2021-11-27
  • 2021-12-15
相关资源
相似解决方案