mysql 1129处理

来源:这里教程网 时间:2026-03-01 15:56:07 作者:

● 1129 - Host '192.168.2.187' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 原因:  同一个ip在短时间内产生太多中断的数据库连接而导致的阻塞(超过mysql数据库max_connection_errors的最大值) 此时观察 log_error=SQL2012.err 发现大量 如下错误 2021-04-09T05:29:39.615273Z 281 [Note] Aborted connection 281 to db: 'diancui' user: 'root' host: 'SKY-20160310GED' (Got an error reading communication packets) 2021-04-09T05:29:39.615273Z 278 [Note] Aborted connection 278 to db: 'diancui' user: 'root' host: 'SKY-20160310GED' (Got an error reading communication packets) 先来查看两个参数: show global status like '%abort%';  +------------------+-------+ | Variable_name    | Value | +------------------+-------+ | Aborted_clients  | 123   |      #表示连接的mysql客户端被kill的数量 | Aborted_connects | 697   |   #表示客户端登录失败的数量 +------------------+-------+ Aborted_clients 可能的原因有: a)客户端没有主动关闭mysql连接mysql_close()。 b)wait_timeout设置很短被mysql干掉了。 c)客户端由于某些原因被干掉了。 Aborted_connects可能的原因有: a)没有授权或者密码不对。一般错误日志中会有如下报错(Access denied for ‘user’@‘host’) b)连接数满了。一般报错包含(too many connections) c)超过链接时间限制,主要有这个参数控制connect_timeout(mysql默认是10s,基本除非网络环境极端不好,一般不会超时。) 解决办法: 方法一: 增加 max_connection_errors 数量, 治标不治本.  set global max_connect_errors = 1000;  show variables like '%max_connection_errors%'; 方法二: mysqladmin flush-hosts -h 127.0.0.1 -uroot -p -P3308 或者在数据库中执行 flush hosts;

相关推荐