1. 停止mysql服务器
> net stop mysql
2. 禁止使用权限表启动服务器
mysqld --console --shared-memory --skip-grant-tables
--console:窗口模式输出日志
--shared-memory:共享内存模式启动
--skip-grant-tables:不使用权限表
3. 重新读取权限表
> mysql
mysql> flush priviables;
4. 修改密码
修改账号'root'@'localhost'
的密码为12345678.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';
5. 重启服务器
按CTRL + C
停止服务器。停止后,重新启动mysql服务器。
> net start mysql
6. 使用新密码登录
> mysql -u root -p
Enter password: 12345678