MySQL8.0忘记root密码解决方法_MySQL8.0 忘记 root 密码下如何修改密码 梦里梦外; 2023-01-11 09:22 195阅读 0赞 环境:Linux centos8 4.18.0-80.el8.x86\_64、Mysql8.0.18 1、vim /etc/my.cnf,添加skip-grant-table(跳过权限验证) ![3bc6ef9e5af422c745d6f80d252b7e9c.png][] 2、重启mysql服务 systemctl stop mysqld //停止服务 systemctl restart mysqld //重启服务 systemctl status mysqld //服务状态查看 ![c7bd6e13fa815feec2f26237bc9617fa.png][] 3、刷新权限表:flush privileges; ![5b59de4e06cb97b522a218a829bb2cba.png][] 4、mysql登录:mysql -uroot -p(无需密码) ![fe2a476e20cd874632e9e9dd7eb5937f.png][] 5、密码重置(Mysql8.0+有变化) 先把root的旧密码置空 use mysql; update user set authentication\_string='' where user='root'; 备注:Mysql5.7+ password字段 已改成 authentication\_string字段 ![7457543ea8200b6c0bb3dba059d8d901.png][] 重置成新密码 alter user 'root'@'localhost' identified by 'newpassword'; 备注:Mysql8.0修改密码方式已有变化(此处是个坑,需要注意) Mysql8.0之前: update user set password=password('root') where user='root'; ![15832d710ee3c1794d97513698840928.png][] 6、vim /etc/my.cnf,删除skip-grant-table 7、再次重启mysql服务 8、使用新密码登录mysql mysql -uroot -proot ![2a54e3fffd3171e7e7bbf608b59ab58b.png][] 本作品采用《CC 协议》,转载必须注明作者和本文链接 阿德 [3bc6ef9e5af422c745d6f80d252b7e9c.png]: /images/20221119/3205d419e636471c819846cccd015b14.png [c7bd6e13fa815feec2f26237bc9617fa.png]: /images/20221119/ca7c6776fa004a27b3027b7f89e3c42e.png [5b59de4e06cb97b522a218a829bb2cba.png]: https://img-blog.csdnimg.cn/img_convert/5b59de4e06cb97b522a218a829bb2cba.png [fe2a476e20cd874632e9e9dd7eb5937f.png]: https://img-blog.csdnimg.cn/img_convert/fe2a476e20cd874632e9e9dd7eb5937f.png [7457543ea8200b6c0bb3dba059d8d901.png]: https://img-blog.csdnimg.cn/img_convert/7457543ea8200b6c0bb3dba059d8d901.png [15832d710ee3c1794d97513698840928.png]: https://img-blog.csdnimg.cn/img_convert/15832d710ee3c1794d97513698840928.png [2a54e3fffd3171e7e7bbf608b59ab58b.png]: https://img-blog.csdnimg.cn/img_convert/2a54e3fffd3171e7e7bbf608b59ab58b.png
还没有评论,来说两句吧...