mysql8.0.18忘记密码问题

mysql8.0.18忘记密码

方法一

  1. 管理员身份进入dos

  2. 停止mysql服务
    net stop mysql

  3. 无密码启动
    C:\Windows\System32>D:\mysql-8.0.18-winx64\bin\mysqld --console --skip-grant-tables --shared-memory

  4. 另启一个dos窗口,无密码登录
    C:\Windows\System32>D:\mysql-8.0.18-winx64\bin\mysql -u root

  5. 清空密码
    注意:authentication_string采用的是plugin加密方式,故设置为空,不要设置为其他值
    mysql> UPDATE mysql.user SET authentication_string=’’ WHERE user=‘root’;

  6. 启动服务
    关闭打开的两个dos窗口,然后以管理员身份重新打开一个dos窗口,启动服务
    net start mysql

  7. 无密码登录
    C:\Windows\System32>D:\mysql-8.0.18-winx64\bin\mysql -u root

  8. 重新设置密码
    alter user root@localhost identified by ’root’;

  9. 新密码登录
    C:\Windows\System32>D:\mysql-8.0.18-winx64\bin\mysql -u root -proot

    原文链接

方法二

  1. 停掉mysql服务

  2. 在mysql.ini下,添加“skip-grant-tables”配置(mysqld这样可以去掉登录时的密码验证)

  3. 重启mysql

  4. 在cmd下输入mysql -uroot -P3306 ,无密码登录

  5. use mysql;

  6. set password=password(‘123’) --error

​ update user set password=password(‘admin’) where user=‘root’ and host=‘localhost’;

  1. 重启,或直接flush privileges;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值