springboot连接数据出现Access denied for user 'root'@'localhost' (using password: YES)

five is me. 2021-05-25 10:16:45
数据库密码都正确,同样的代码 第二台电脑跑的起来,这个电脑跑不起来

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in file [D:\chyx\chuhui\ch-user\service\target\classes\com\wyqf365\user\mapper\UserMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
...全文
1405 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
冰思雨 2021-06-21
  • 打赏
  • 举报
回复

你连接的是本地数据库。问题出在本地数据库上面。

第二台的数据库,与当前这台机器的数据库,配置不相同。

正如楼上几位说的,把 root 的本地访问权限添加一下试试。

或者,你是不是要连接同一个数据库啊? 如果是的话,更改一下 localhost ,把地址改到目标主机,并且添加 root 的访问权限。

  • 打赏
  • 举报
回复
雨润泽林 2021-05-26
  • 打赏
  • 举报
回复 1
看这篇文章,最后有解决方案:https://blog.csdn.net/qq_17555933/article/details/117229900?spm=1001.2014.3001.5501
five is me. 2021-05-25
  • 打赏
  • 举报
回复
引用 1 楼 Little BigUs 的回复:
root 用户没有访问权限
有本地的访问权限,刚看过
Little BigUs 2021-05-25
  • 打赏
  • 举报
回复
root 用户没有访问权限
  • 打赏
  • 举报
回复
我之前也遇到过类似的问题,就是代码都没问题;重建一个项目,完全一摸一样的代码就能跑起来;
Java全栈路线 2021-05-25
  • 打赏
  • 举报
回复
数据库权限的问题,得进mysql里面开启权限

use mysql;
grant all on *.* to 'root'@'%' with grant option;
flush privileges;
韩_师兄 2021-05-25
  • 打赏
  • 举报
回复
root用户没有权限,在mysql里面先给权限就好了
a1767028198 2021-05-25
  • 打赏
  • 举报
回复
debug数据源实例化的过程,去看看到底密码是什么
  • 打赏
  • 举报
回复
检查下yml的配置文件是否正确,看下数据库是否授权

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧