我是靠谱客的博主 高兴天空,这篇文章主要介绍Caused by: java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES),现在分享给大家,希望可以做个参考。

Springboot项目连接数据库报错:Caused by: java.sql.SQLException: Access denied for user ‘root’@‘localhost’ (using password: YES)

项目环境

项目和数据库在Docker中运行,并配置有mysql容器的docker网络parkingmysql。

原因

1.密码错误。
2.application.yml中数据库账号地址错误
在这里插入图片描述
一般是 jdbc:mysql://localhost:3306/database,这里的parkingmysql是docker中创建的网络。

3.application.yml中数据库账号的密码配置误导引起错误。

在这里插入图片描述

该配置中密码是 ‘123456’,我天真的以为是有单引号的!
去掉单引号使用sql语句修改成功!

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
docker exec -it mysql bash # 登录 mysql mysql -uroot -p # mysql> # 更新权限 flush privileges; # 授权 Grant all on databasename to 'username'@'localhost' identified by 'passwd123'; # 更新权限 flush privileges;

最后

以上就是高兴天空最近收集整理的关于Caused by: java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)的全部内容,更多相关Caused内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部