1 知道 mysql 路径下面的文件 D:mysqlmysql-8.0.18-winx64 ->my.ini
2 在[mysqlid] 添加下面2句话 然后保存
shared-memory
skip-grant-tables
3 以管理员的命令允许命令窗口
4停止mysql服务
net stop mysql
5启动mysql 服务,输入root 用户- 随便输入密码
C:WINDOWSsystem32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
C:WINDOWSsystem32>mysql -u root -p
6 切换到mysql 数据库 修改user表 root 用户 密码
mysql> update user set authentication_string='' where user='root';
Query OK, 1 row affected (0.16 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'root';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)
mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.07 sec)
mysql> exit;
7 干掉之前的2行数据,停掉服务器,重新启动服务器。输入新密码就ok了



