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

换了电脑后,导入原来的javaWeb项目,运行项目出现以下提示:
java.sql.SQLException: Access denied for user ‘root’@’localhost’ (using password YES)
分析:
1.用户名或者密码或者驱动没有写好—–>检查配置文件修改
2.权限问题
我的情况属于2
我几天按照网上各种办法都试过修改权限,有的简单有的复杂,仍然不成功…….在我快要放弃的时候看到有位大哥的方法,仅有一命令,我试了试竟然成功了!现在分享给各位小伙伴:
首先进入mysql数据库,然后输入:
grant all privileges on . to [email protected]”%” identified by “.”;
如下图所示:
完美解决java.sql.SQLException: Access denied for user 'root'@'localhost' (using password YES)
然后启动项目,直接起飞:
完美解决java.sql.SQLException: Access denied for user 'root'@'localhost' (using password YES)