**
服务器项目连接不上mysql
**
Caused by: org.flywaydb.core.internal.exception.FlywaySqlException:
Unable to obtain connection from database: null, message from server: "Host '39.100.23.202' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
问题原因:将如上错误搜索后会出现很多答案,大体上是说因为请求mysql连接错误过多,导致mysql拒绝来自该服务器ip的连接,多数解决方案如下:
1)修改mysql的最大连接错误数(max_connect_errors)
#查看服务器ip的连接数
mysql> select SUM_CONNECT_ERRORS as count from performance_schema.host_cache where ip='39.100.23.202';
+-------+
| count |
+-------+
| 100 |
+-------+
1 row in set (0.01 sec)
# my.cnf文件将max_connect_errors连接数设置为(默认是100)
mysql> show variables like 'max_connect_errors';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 100 |
+--------------------+-------+
1 row in set (0.00 sec)
# 通过修改my.cnf文件将max_connect_errors连接数设置为1000(默认是100)
mysql> set global max_connect_errors=1000;
Query OK, 0 rows affected (0.00 sec)
#查看是否修改成功
mysql> show variables like 'max_connect_errors';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 1000 |
+--------------------+-------+
2)重新刷新mysql的host权限
使用命令刷新
[root@yumaster ~]# /usr/bin/mysqladmin flush-hosts -h ${mysqlIp} -uroot -p
# 不知道位置可通过whereis查看
[root@yumaster ~]# whereis mysqladmin
mysqladmin: /usr/bin/mysqladmin /usr/share/man/man1/mysqladmin.1.gz
或者使用mysql命令刷新
mysql> flush hosts;
问题完美解决。