首先在mysql文件 bin目录下net stop mysql  关闭mysql服务 并查看任务管理器中是否存在mysql.exe 如果存在禁用此服务

当关闭之后 点击开始 输入CMD   右键以管理员方式打开WIN命令操作

Mysql 忘记密码 解决 并附加中间遇到的问题

 

定位到你的Mysql安装包目录

Mysql 忘记密码 解决 并附加中间遇到的问题

当定位到bin下时输入mysqld --console --skip-grant-tables --shared-memory 关闭服务 (适用于8.0以上版本)

如果是其他版本 可以用mysqld -nt --skip-grant-tables 

输入完成后打开新的窗口 同样定位到bin下 输入mysql

show databases

use mysql

然后查询 select user,host,password from user; 

查询时有可能没有password  如果查不到 改为authentication_string

修改 update mysql.user set password=password('123456') where user='root' and host='localhost';

如果没有password  改为authentication_string 

改为authentication_string 时仍报错

修改语句ALTER USER '账号root'@'localhost' IDENTIFIED WITH mysql_native_password BY  '密码root';

flush privileges刷新

重启mysql 登录成功

 

 

 

 

相关文章: