Could not create connection to database server. Attempted reconnect 3 times. Giving up.
程序员文章站
2022-05-01 15:55:20
...
在启动服务时,报出Could not create connection to database server. Attempted reconnect 3 times. Giving up.这个错误。报错图:
这是我的 application.yml 配置信息:
spring:
application:
name: softactivity
http:
encoding.charset: UTF-8
encoding.force: true
mvc:
static-path-pattern: /**
resources:
static-locations: classpath:/templates/
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/works?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true&&allowMultiQueries=true&verifyServerCertificate=false
username: root
password: root
jpa:
database: MYSQL
show-sql: true
查看多次,上网查询修改了多次,都还是报这个错误。
最终发现因 mysql-connector-java 中的jar版本太高,与自己的mysql版本不符,在这里插入代码片
所导致的错误,将jar的版本调到6.0以下即可。本人最终将jar的版本换成了5.1.30,配置信息没有问题,错误解决。
如果还未解决您的问题,请检查配置的正确性或其他:
datasource:
driver:xxxx
url: xxxx
username: xxxx
password: xxxx
推荐阅读
-
pycharm连接mysql是出现Connection to orm02@127.0.0.1 failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
idea连接MySQL报错Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
pycharm连接mysql是出现Connection to orm02@127.0.0.1 failed. [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
-
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.