- 以管理员身份运行控制台,关闭MySQL服务
net stop mysql
- 跳过授权表,进行免密登录
mysqld --console --skip-grant-tables --shared-memory
- 用管理员身份新打开一个控制台窗口,然后免密码登录Mysql
mysql
- 使用MySQL的mysql数据库
use mysql
- 先修改root的密码为空。特别注意authentication_string=‘’的等号后面是一对单引号
update mysql.user set authentication_string=' ' where user='root';
- 在上一步的基础上查询root的用户分组和密码
select host,user,authentication_string from mysql.user;
# 修改之后可以看到,root用户的密码已经为空
- 打开新的窗口,启动MySQL的服务
net start mysql