站点图标 起风网

Access Denied for user root @localhost 解决方案

问题描述: 
C:\Users\bo.wang> mysql -u root -p 
Enter password: 
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

解决步骤: 
step1:修改mysql配置文件my.int,添加skip-grant-tables并保存。 

step2:重启mysql服务。 

step3:修改root密码 
C:\Users\bo.wang>mysql

mysql> use mysql 
Database changed 
mysql> update user set password=password(“123456”) where user=”root”; 
Query OK, 0 rows affected (0.00 sec) 
Rows matched: 1 Changed: 0 Warnings: 0

mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

mysql> exit 

step4:通过navicat或者其他可视化工具连接mysql查看mysql库里的user表,修改root用户的权限(密码是加密过的,不要乱改) 

step5:重新修改my.ini,注释skip-grant-tables命令行,保存重启mysql服务

文章转载于:https://www.cnblogs.com/lm970585581/p/9309350.html

原著是一个有趣的人,若有侵权,请通知删除

退出移动版