MySQL 8.0出现 Access denied for user 'root'@'localhost' ;忘记密码的解决方法;跳过权限检查

1.管理员权限运行cmd

2.停止MySQL服务

命令行输入net stop mysql

3.跳过权限检查

现在mysqld -skip-grant-tables命令在8.0中没有用了!!!(我之前试了很多遍这个命令,包括在my.ini添加和在命令行中运行,试到崩溃……)

改为使用mysqld --console --skip-grant-tables --shared-memory

4.无密码登陆

另开一个管理员运行的cmd,使用mysql -u root -p命令,出现“enter password:”时直接按回车键,实现无密码登陆

5.改密码

mysql8.0之前更改root密码,输入update user set password=password('123456') where user='root' and host='localhost';因为mysql8.0之前密码字段是"password";

现在的字段是"authentication_string",所以改密码方式也有所变化

使用命令 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ‘你的密码’;

但是出现错误“The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement”,具体原因应该是–skip-grant-tables在命令行的时候,使得数据库只能是只读的权限。

使用命令:mysql> flush privileges;

再使用一次改密码命令即可

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Louie_0

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值