当前位置:   article > 正文

java.sql.SQLException: Access denied for user ‘root’@‘localhost’ (using password: YES)错误原因_java.sql.sqlexception: access denied for user 'roo

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

java.sql.SQLException: Access denied for user ‘root’@‘localhost’ (using password: YES)错误原因 解决方案:

  1. 用户对应的密码不正确
    检查输入的用户名 密码 与数据库用户名 密码 是否一致
    这里密码不正确有几种常见情况:
    (1)连接池多个空格
    (2)mysql5.7后mysql系统表user里密码对应的字段不是password
    是authentication_string字段
    命令行依次输入:
mysql
use mysql;
select * from user where user='你的用户名'\G;
  • 1
  • 2
  • 3

在这里插入图片描述
authentication_string为5.7后mysql的密码字段
在这里插入图片描述
password原来的密码字段
然后更新:

update user set authentication_string=password('你的密码') where user='你的用户名';
  • 1
  1. localhost映射问题
    在这里插入图片描述
    localhost换成127.0.0.1

3,第三种可能就是MYSQL的权限问题

GRANT
  [权限] 
ON [.] 
TO [用户名]@[IP] 
IDENTIFIED BY [密码] 
# WITH GRANT OPTION;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

示例:

GRANT
  ALL PRIVILEGES
ON *.*
TO admin@'175.155.59.133'
IDENTIFIED BY 'admin';

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

每次更新权限后记得刷新权限
FLUSH PRIVILEGES;

在这里插入图片描述

权限问题具体参看这篇博文:
https://blog.csdn.net/weixin_42109012/article/details/102684153

4,数据库和驱动不匹配
https://blog.csdn.net/qq_41679818/article/details/105857793

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号