终极解决办法:MySQL Access denied for u
2018-07-22 本文已影响1人
胡萝卜须摇头玩
1.在cmd中,输入“services.msc”,打开服务
![](https://img.haomeiwen.com/i4049324/06abee6a11d08f5f.png)
2.找到MySQL服务,右键查看属性
![](https://img.haomeiwen.com/i4049324/0760a4b64bf55979.png)
3.在“可执行文件的路径”中,“--defaults-file”前面为mysql的执行文件路径,后面为配置文件路径。复制配置路径并用记事本打开“my.ini”文件(如“C:\ProgramData\MySQL\MySQL Server 5.7\my.ini”)
![](https://img.haomeiwen.com/i4049324/1965581547af3289.png)
4.搜索“[mysqld]”,在其下一行加上“skip-grant-tables”,保存并退出
![](https://img.haomeiwen.com/i4049324/f9804ad216ab884e.png)
5.重启MySQL服务
![](https://img.haomeiwen.com/i4049324/bce879e06a022f2a.png)
6.cd到MySQL的bin目录,依次输入以下命令并换行:
cd C:\Program Files\MySQL\MySQL Server 5.7\bin
use mysql;
update user set authentication_string=password("kris925122") where user="root";
flush privileges;
![](https://img.haomeiwen.com/i4049324/7a84a9ad6d3dd88a.png)