mysql忘记密码怎么办

8.0以上的版本

 1.使用管理员权限打开命令提示符,在命令行中输入: net stop mysql 

2.待mysql服务停止后,输入: mysqld --shared-memory --skip-grant-tables ,此时命令提示符窗口处于锁定状态,我们重新以管理员权限打开新的命令提示符窗口。

3.在新的命令提示符窗口输入: mysql -uroot -p 后回车,提示输入密码时直接按回车进入。

4.输入: use mysql; 

5.输入: update user set authentication_string='' where user='root'; ,将authentication_string置空。

注:在mysql8.0以上版本,

 update mysql.user set password='newpassword' where user='root';

 和

 update mysql.user set password=PASSWORD('newpassword') where User='root'; 这两条命令已经不起作用了。

6.输入: alter user 'root'@'localhost' identified by 'newpassword'; newpassword是要设的新密码。

我的操作到这一步出现error;

后来先执行:

flush privileges;

再执行:

alter user 'root'@'localhost' identified by 'newpassword';

则执行成功。

再从SQLyog用新密码登录就可以了

转载:https://www.cnblogs.com/mzxiaoze/p/10413399.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值