服务器上部署springboot项目的时候启动项目报错连接数据库问题

Fri Feb 07 10:36:05 CST 2020 WARN: Establishing SSL connection without server’s identity verification is not recommended. According
to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For
compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to expl
icitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
2020-02-07 10:36:05.362 ERROR[Druid-ConnectionPool-Create-221634215]com.alibaba.druid.pool.DruidDataSource.run:2471 -create connect
ion SQLException, url: jdbc:mysql://122.152.202.76:3305/xtj_contract?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=co
nvertToNull, errorCode 1045, state 28000

以上问题是由于有时候一些版本的需要在连接数据库的时候在最后面写上useSSL=true,

解决完以上问题后又出现一个问题,
useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true

2020-02-07 10:43:02.670 ERROR[Druid-ConnectionPool-Create-221634215]com.alibaba.druid.pool.DruidDataSource.run:2471 -create connect
ion SQLException, url: jdbc:mysql://122.152.202.76:3305/xtj_contract?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=co
nvertToNull&useSSL=true, errorCode 1045, state 28000

这个问题的出现有可能是你当前服务器的ip地址,数据库不允许被连接,这个时候就要进去数据库查看当前数据库和允许连接的ip

首先进入数据库

mysql -u用户名 -p密码 

然后

use mysql

查询数据库自带的user表

 select host,user from user;

如果出现你使用的用户名后面是localhost的时候可能就有问题,直接使用更新语句将项目中使用的用户名修改为%,这个语句在之前的博客中写过,如果需要自己看吧。

然后查看到内容是这样的。
在这里插入图片描述
然后只要在启动脚本中写对用户名和密码就可以成功启动项目,如果你写错了用户名对应的密码也有可能会报告以上错误,查看日志发现正常启动。

如果解决了你的问题点个赞吧

猜你喜欢

转载自blog.csdn.net/qq_42584411/article/details/104207105