
1、管理员身份打开命令行
net stop mysql
2、跳过用户验证
mysqld --skip-grant-tables
3、管理员身份打开新窗口,输入
mysql
4、进入mysql数据库
use mysql;
5、重新设置密码
update user set password=password('123456') where user='root' and host='localhost';
如果出现以下错误,则将命令改为
update user set authentication_string=password('123456') where user='root' and host='localhost';
修改后exit退出
6、启动mysql服务并登录
net start mysql
mysql -uroot -p123456
网友评论