springboot链接数据库,怎么错了?,密码没问题

img

img

img

img


2023-02-26 23:02:09.890 ERROR 31120 --- [nio-8081-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)] with root cause

首先保证数据库的已正常启动,
其次保证数据库的链接密码正确。
再次保证数据库的远程连接权限已经设置打开:
cmd进入数据库
use mysql然后
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
123456修改为你的数据库密码。这里表示允许任何电脑通过密码来访问。
最后刷新权限flush privileges;
如果你不太会,详细可以参考其它资料:https://blog.csdn.net/weixin_44451527/article/details/127690479

你可以试着往以下几个方面排查
①数据库服务是否开启
②导入的依赖是否符合数据库版本,比如mysql8就要导入cj的那个
③试者把jdk换成1.8试试

你的数据库密码错了

img

img

img

img

ok完美解决爱了