美文网首页
Linux下忘记MySQL密码

Linux下忘记MySQL密码

作者: 这真的是一个帅气的名字 | 来源:发表于2019-04-02 17:32 被阅读0次

    1、用命令编辑/etc/my.cnf配置文件,即:vim /etc/my.cnf

    2.在[mysqld]下添加skip-grant-tables,然后保存并退出


    image.png

    修改密码UPDATE mysql.user SET Password=PASSWORD('新密码') where USER='root';
    如果是5.7版本运行update mysql.user set authentication_string=password('root') where user='root' ;即可
    因为5.7把密码地段换成了authentication_string
    刷新权限flush privileges;
    最后把/etc/my.cnf中的skip-grant-tables注释掉,然后重启mysql,即:service mysqld restart

    image.png
    重新登陆MySQL
    image.png

    相关文章

      网友评论

          本文标题:Linux下忘记MySQL密码

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