[只是我问题的伪解决]执行Springboot程序连接数据库被拒绝

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

错误

1、com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

2、The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

3、Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

4、java.net.ConnectException: Connection refused

我是复制这些错误日志百度搜索的
错误1 一般说的是mysql版本和驱动问题。
mysql5.7 可以用驱动5.1.x 也可以用8.0.x

8.0
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/folksongdatabase?characterEncoding=utf8&useSSL=true&serverTimezone=UTC

5.1
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/useSSL=true&useUnicode=true&characterEncoding=UTF-8

还有说是密码错误,我这次是本地可以使用,就打jar包之后通过idea Docker插件部署到服务器Docker容器运行会报上面的错误
看了挺多博客的,对于这种版本问题看官网比较靠谱
mysql官网

错误2

  1. 有可能windows下mysql服务没启动,但是我的是linux docker环境下mysql容器,确认是启动的。
  2. 数据库缓存池时间啥问题,说实话没看懂,没敢照着改。。。
    两种解决异常:“The last packet sent successfully to the server was 0 milliseconds ago. ”的办法…
    感觉很有道理的,但是我的就离谱,之前部署的一个spingboot项目可以正常连接mysql这次部署的就不行,对同一个数据库当前时间下可以

错误3
搜出来还是版本问题
错误4
依旧是要么版本问题,要么windows未启动服务

我的解决

我就试试,搜了好久也改了好久都没成功,真就试试就可以了。。。
spring.datasource.url=jdbc:mysql://localhost:3306/folksongdatabase?characterEncoding=utf8&useSSL=true&serverTimezone=UTC

我把localhost改成了我服务器ip地址就好了!!!

吐槽

期间还经历了服务器100%cpu。。。被挖矿程序占用了,我的是自己用学生服务器100一年的那种,压根没想过服务器安全防护,端口一开就全部。。。密码(你猜)
Linux云服务器挖矿病毒(crypto和pnscan)导致CPU占用100%问题解决方案
这篇博主写的完美匹配我的问题,一top果真看到了crypto和pnscan,一个占cpu70% 一个10% 不过只删掉一个的话 cpu还是100%
chattr命令被篡改
这里挖矿病毒crypto和pnscan可能是idea发布到Docker过程出现了问题

解决 二 docker安装ca证书

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值