连接mysql 错误号码1129:

mysql error 1129: Host 'bio.chip.org' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'。

解决方法:

在连接不上的那个MySql连接的本地服务器运行

1.

cmd命令行:

mysqladmin flush-host -h 127.0.0.1 -u root -p

输入密码

解决。

2.

进入Mysql, 运行:

flush-host;

会显示:Query OK, 0 rows affected (0.03 sec)

解决。

解决方法比较多,不过有些方案都是临时方案。临时方案是指标不治本。关键还是需要解决网络错误(这个往往需要求助网络管理人员或系统管理员)

1)将变量max_connection_errors的值设置为一个更大的值

这个临时方案只是延迟触发IP被禁止访问的条件而已,而且在复杂情况或高并发的情况下,需要设置一个很大的值,否则很容易就会再次被触发。另外,变量只对当前环境生效,如果重启就会失效,如果需要永久有效,可以在my.cnf配置文件里面配置。

mysql> show variables like 'max_connect_errors';

+--------------------+-------+

| Variable_name      | Value |

+--------------------+-------+

| max_connect_errors | 3     |

+--------------------+-------+

1 row in set (0.03 sec)


mysql> set global max_connect_errors=150;

Query OK, 0 rows affected (0.00 sec)

2)使用flush hosts

#方式一

mysql> flush hosts;

Query OK, 0 rows affected (0.00 sec)


mysql> select * from performance_schema.host_cache\G

Empty set (0.00 sec)


#方式二

[root@docker01 ~]# mysqladmin -uroot -pmysql flush-host

host cache解释说明:

The MySQL server maintains a host cache in memory that contains information about clients: IP address, host name, and error information. The server uses this cache for nonlocal TCP connections. It does not use the cache for TCP connections established using a loopback interface address (127.0.0.1 or ::1), or for connections established using a Unix socket file, named pipe, or shared memory.

MySQL服务器在内存中维护一个包含客户端信息的缓存:IP地址,主机名和错误信息等。 服务器会将非本地TCP连接信息缓存起来。它不会缓存使用环回接口地址(127.0.0.1或者:: 1)建立的TCP连接,或者使用Unix套接字文件,命名管道或共享内存建立的连接。host cache信息可以通过performance_schema数据库下的host_cache表查询。

3)将变量host_cache_size设置为0

最不靠谱的解决方法,只是让MySQL服务器不记录host cache信息而已。完全可以忽略这个方法

mysql> show variables like '%host_cache_size%';

+-----------------+-------+

| Variable_name   | Value |

+-----------------+-------+

| host_cache_size | 279   |

+-----------------+-------+

1 row in set (0.00 sec)


mysql> set global host_cache_size=0;

Query OK, 0 rows affected (0.00 sec)


mysql> show variables like '%host_cache_size%';

+-----------------+-------+

| Variable_name   | Value |

+-----------------+-------+

| host_cache_size | 0     |

+-----------------+-------+

1 row in set (0.00 sec)


mysql> select * from performance_schema.host_cache;

Empty set (0.00 sec)


转载于网络

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容