错误提示:玩若依框架遇到的一个错误
09:56:43.704 [main] ERROR c.a.d.p.DruidDataSource - [init,928] - init datasource error, url: jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130)
解决办法:
1.登录mysql
> mysql -u root -p
输入密码
2.
>use mysql
重置密码
> update user set authentication_string='' where user='root';
>flush privileges;
>select user,host from user;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
总结:
- 根据字面意思判断是mysql数据库没有访问权限,经排查是mysql数据库用户root没有设置密码,但是springboot项目设置的mysql密码是root,
- 修改又提示各种没有权限错误,发现都是caching_sha2_password的插件,而不是mysql_native_password插件
- 使用update user set plugin='mysql_native_password' where user='root';修改下插件选择
- 最后按照上面的解决办法成功解决