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

1、用户名密码错误

打开命令窗口,进入MySQL的bin目录,一般是在C:\Program Files\MySQL\MySQL Server 5.7\bin,输入命令:

mysql -u [username] -p

MySQL报错:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)_第1张图片

如果能进不去,则是用户名密码错误。如果能进去,则不是这个问题。

2、没有权限

在workbench的左上方的user and privilege中查看自己选中的用户的schema privileges,

MySQL报错:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)_第2张图片

如果什么都没有,则在query中执行命令:

GRANT ALL PRIVILEGES ON [databasename].[tablename]TO ‘user’@’host’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

例如:
GRANT ALL PRIVILEGES ON wechatvideo.* TO 'root'@'host' IDENTIFIED BY '123456' WITH GRANT OPTION;

3、把工程用maven重新编译一下

 

你可能感兴趣的:(MySQL)