create connection SQLException, url: XXXXXX, errorCode 0, state 08001
关于这个问题 百度了两个多小时 网上众说纷纭但是一个顶用的都没有,首先关注点并不在这里 而是在如下
2022-12-18 01:30:56.022 ERROR 57546 --- [eate-1740826931] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: XXXXXXXXXX, errorCode 0, state 08001java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:898) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:448) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1651) at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1717) at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2785)Caused by: com.mysql.cj.exceptions.CJException: null, message from server: "Host 'XXXXXX' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
Caused by: com.mysql.cj.exceptions.CJException: null, message from server: “Host ‘XXXXXX’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’”
主要问题是这行 意思呢大概就是连接错误次数达到上限 所以被mysql把错误上限得到IP拉黑了
找到问题的原因了 接下来就好解决了 解决问题的办法也就在问题的结尾
我们到服务器连接上Mysql 然后执行
flush hosts;
再次启动项目 连接正常搞定
来源地址:https://blog.csdn.net/weixin_42436477/article/details/128359247