zoukankan      html  css  js  c++  java
  • mysql max_connections_errors过大导致无法连接

    前言

    今天同事跟我反应,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)
      
  • 相关阅读:
    77. Combinations
    76. Minimum Window Substring
    75. Sort Colors
    74. Search a 2D Matrix
    73. Set Matrix Zeroes
    72. Edit Distance
    71. Simplify Path
    70. Climbing Stairs
    线段树+欧拉函数——cf1114F
    区间dp——好题cf1132F
  • 原文地址:https://www.cnblogs.com/young233/p/13441930.html
Copyright © 2011-2022 走看看