1、打开MySQL目录下的my.ini文件,在文件的最后添加一行“skip-grant-tables”,保存并关闭文件。
2、重启MySQL服务。
3、在命令行中输入“mysql -uroot -p”(不输入密码),回车即可进入数据库。
4、执行,“use mysql;”使用mysql数据库。
5、执行,“update user set password=PASSWORD("111111") where user='root';”(修改root的密码)
(期间我还select下user表中的记录,查询全部的时候显示了一些乱码,然后我只查询了user表中的Host、User、Password字段,貌似当时显示了3条记录,有1个没有名称。当然,为了解决问题,这些我也管不了了。)
6、打开MySQL目录下的my.ini文件,删除最后一行的“skip-grant-tables”,保存并关闭文件。
7、重启MySQL服务。
8、在命令行中输入“mysql -uroot -prootadmin”,问题搞定!![Access <wbr>denied <wbr>for <wbr>user <wbr>'root'@'localhost' <wbr>(using <wbr>password:YES) <wbr>解决方案 Access <wbr>denied <wbr>for <wbr>user <wbr>'root'@'localhost' <wbr>(using <wbr>password:YES) <wbr>解决方案](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6719EN00SIGG.gif)
![Access <wbr>denied <wbr>for <wbr>user <wbr>'root'@'localhost' <wbr>(using <wbr>password:YES) <wbr>解决方案 Access <wbr>denied <wbr>for <wbr>user <wbr>'root'@'localhost' <wbr>(using <wbr>password:YES) <wbr>解决方案](http://www.sinaimg.cn/uc/myshow/blog/misc/gif/E___6719EN00SIGG.gif)