美文网首页足迹
找回重置 root 密码

找回重置 root 密码

作者: qyfl | 来源:发表于2019-03-16 22:20 被阅读0次
  1. 编辑 MySQL 配置文件 /etc/my.cnf

  2. 在 [mysqld] 中增加一行,用来跳过授权表的验证

    skip-grant-tables

  3. 重启 MySQL 服务。

  4. 直接使用 mysql -uroot -p 两次回车,不用输入密码就可以直接登录。登陆过后使用以下两行命令就可以修改密码了。

    use mysql;

    update user set authentication_string=password('newPassword') where user='root';

    或者

    update mysql.user set password=password('新密码') where User="admin" and Host="localhost";

    两个命令赋予的 Host 不同,更新密码的字段也不同。

  5. 刷新权限

    flush privileges;

相关文章

网友评论

    本文标题:找回重置 root 密码

    本文链接:https://www.haomeiwen.com/subject/vcmemqtx.html