当前位置:   article > 正文

【解决报错】java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

java.sql.sqlexception: access denied for user 'root'@'localhost' (using pass

IDE:IntelliJ IDEA Ultimate 2019.3 (我用的是学生版,只要大学邮箱能用就可以的)

报错信息全文附在最后。其中关键的信息就是:

Root Cause

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

解决方法

1.首先,如果项目是你下载的,数据库的账户密码一定都要改好。

2.设置Mysql初始化root密码和允许远程访问:

(1)进入mysql数据库

mysql>update user set password=PASSWORD(‘123456’) where User='root';

(2)授权使Mysql被允许远程访问

  1. mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
  2. mysql>FLUSH PRIVILEGES;

 

报错信息全文

  1. Exception
  2. org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
  3. ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
  4. ### The error may exist in file [/Users/ching_shing/Downloads/JavaEETest-master/MyBlog/target/MyBlog/WEB-INF/classes/mapping/ArticleMapper.xml]
  5. ### The error may involve org.sang.dao.ArticleDao.getFirst10Article
  6. ### The error occurred while executing a query
  7. ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
  8. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
  9. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
  10. javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
  11. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
  12. javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  13. org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  14. Root Cause
  15. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
  16. ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
  17. ### The error may exist in file [/Users/ching_shing/Downloads/JavaEETest-master/MyBlog/target/MyBlog/WEB-INF/classes/mapping/ArticleMapper.xml]
  18. ### The error may involve org.sang.dao.ArticleDao.getFirst10Article
  19. ### The error occurred while executing a query
  20. ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
  21. org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
  22. org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
  23. com.sun.proxy.$Proxy27.selectList(Unknown Source)
  24. org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
  25. org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
  26. org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
  27. org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
  28. com.sun.proxy.$Proxy28.getFirst10Article(Unknown Source)
  29. org.sang.service.ArticleService.getFirst10Article(ArticleService.java:29)
  30. org.sang.controller.ArticleController.index(ArticleController.java:33)
  31. java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  32. java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  33. java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  34. java.base/java.lang.reflect.Method.invoke(Method.java:564)
  35. org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
  36. org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
  37. org.springframework.web.servlet.mvc.metho
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/803946
推荐阅读
相关标签
  

闽ICP备14008679号