原创文章链接:https://blog.csdn.net/u013580397/article/details/89817347
Windows 中,Mysql 8.0 修改密码过程和 Mysql 5.6 及之前的版本有所区别。
- 首先,在管理员权限 CMD 中用
net stop mysql
关闭服务,并以以下命令行开启服务,并绕过权限检查
1 mysqld --console --skip-grant-tables --shared-memory
- 然后,启动另一个 CMD 命令行,输入
mysql -u root
直接登陆,接着输入以下命令,将 root 密码置为空。
1 UPDATE mysql.user SET authentication_string='' WHERE user='root' and host='localhost';
- 最后,关闭两个 CMD,通过
net start mysql
启动 mysql 服务,输入mysql -u root
直接登陆,通过以下命令设置 root 用户的密码。
1 ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password';