mysql8忘记密码后,重新设置密码
1.先停止mysql服务

2.跳过认证:以管理员的身份打开命令窗口,输入下面内容
mysqld --console --skip-grant-tables --shared-memory

3.然后再以管理员身份打开一个新的cmd命令窗口,依次输入以下命令
mysql
use mysql

输入以下命令,密码设置为空(authentication_string采用的是plugin加密方式,故设置为空,不要设置为其他值,设置为其他值是不能登录)
update user set authentication_string='' where User='root';
PS:如果是之前的版本,则需要输入:
update user set password=password('XXX') where user='root' and host='localhost';
4.关闭打开的两个cmd命令窗口,然后重新打开一个新的窗口,重新启动服务,无密码登录mysql:
net start mysql
mysql -u root

5.修改密码:
alter user root@localhost identified by 'root';
退出登录:
quit
使用新密码登录:

密码更新完成!
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
