MySql Host is blocked because of many connection errors

1.错误情况

Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

2.原因

从异常信息可以得知就是出现了太多的链接错误。可能原因有,错误的请求、连接超时过多等等。

3.解决

3.1如何解决

https://dev.mysql.com/doc/refman/8.0/en/host-cache.html#host-cache-flushing

  • Change the value of the host_cache_size system variable. This requires the SYSTEM_VARIABLES_ADMIN privilege (or the deprecated SUPER privilege).

  • Execute a TRUNCATE TABLE statement that truncates the Performance Schema host_cache table. This requires the DROP privilege for the table.

  • Execute a FLUSH HOSTS statement. This requires the RELOAD privilege.

  • Execute a mysqladmin flush-hosts command. This requires the DROP privilege for the Performance Schema host_cache table or the RELOAD privilege.

3.2 host_cache 内部有什么

https://dev.mysql.com/doc/refman/8.0/en/performance-schema-host-cache-table.html

4.可问题还没解决

通过flush hosts 清除了被锁的信息,可以正常地访问数据库了。但是同一台机器上的其他服务却可以进行访问数据,难道锁的不是整个ip吗?

mysql中的host

从https://dev.mysql.com/doc/refman/8.0/en/performance-schema-hosts-table.html可以看到host 是

  • The host from which the client connected. This is NULL for an internal thread, or for a user session that failed to authenticate.

通过指令能够更加清楚明白。

mysqladmin proc stat
mysqladmin proc stat.png

host是指程序运行的ip+端口

你可能感兴趣的:(MySql Host is blocked because of many connection errors)