1、停掉mysql 服务
2、输入命令mysqld --console --skip-grant-tables --shared-memory ,跳过授权表
3、另开个管理员cmd窗口,输入mysql 进入mysql服务
4、输入use mysql进入mysql数据库,然后进行密码更新命令为:
UPDATE user SET authentication_string="123456" WHERE user="root";
- mysql> USE mysql;
- Database changed
- mysql> UPDATE user SET authentication_string="123456" WHERE user="root";
- Query OK, 1 row affected (0.39 sec)
- Rows matched: 1 Changed: 1 Warnings: 0
-
- mysql> FLUSH privileges; # 刷新保存
- Query OK, 0 rows affected (0.13 sec)