在使用mysql8.0遇到的坑

在做springboot项目时连接的是MySQL数据库可是老是提示

Could not create connection to database server.

然后我排除了账号密码的错误,最终推测为驱动的问题,在原来版本的mysql中是使用

"com.mysql.jdbc.Driver"

去连接,但是在MySQL8.0要用

"com.mysql.cj.jdbc.Driver"

ps:即使你换了可能还会报错出现时区问题你只需要在你的数据库后面加上一串话
例如:

connectionURL="jdbc:mysql://localhost:3306/gx?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8" userId="root"
发布了12 篇原创文章 · 获赞 9 · 访问量 443

猜你喜欢

转载自blog.csdn.net/weixin_43997477/article/details/101011791