记录 message from server: “Host ‘172.16.12.92‘ is blocked because of many connection errors; unbl

记录 "Host 'ip.' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts问题解决办法'"

产生原因,项目部署在k8s上面,由于断电自动启动失败,导致k8s服务不断访问另外一台mysql数据库,然后下面报错

Caused by: java.sql.SQLException: null,  message from server: "Host '172.16.12.92' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

排查:mysql数据库本地能正常远程访问,
日志是说ip连接太多次,要使用mysqladmin flush-hosts这个命令刷新权限。我想估计是请求太频繁被mysql阻止了。
解决办法:在mysql命令行或者navicat工具输入下面sql查询当前max_connect_errors的数量

show global variables like '%max_connect_errors%';

看到默认是100,然后设置大一点

set global max_connect_errors=1000;

设置完成后刷新权限

flush hosts;

重新访问便成功连接了。

你可能感兴趣的:(java,k8s,mysql)