美文网首页
MySQL忘记管理员密码

MySQL忘记管理员密码

作者: 笑笑东风 | 来源:发表于2019-02-13 21:24 被阅读0次

    忘记MYSQL管理员密码如root用户密码,可以按照以下方式来修改

    STEP1: 停止MySQL服务

    
    ps -ef | grep -v 'grep' | grep 'mysqld' | awk '{print $2}' | xargs kill -9
    
    

    STEP2: 以忽略权限方式启动MYSQL服务

    
    /export/servers/mysql/bin/mysqld --skip-grant-tables --explicit_defaults_for_timestamp --user=mysql &
    
    

    STEP3: 更新管理员密码

    
    ## MySQL5.6版本更新密码
    update mysql.user set password=password("abc@123.com") where user="root";
    ## MySQL5.7版本更新密码
    update mysql.user set authentication_string=password("new_pass") where user="root";
    ## 刷新权限
    flush privileges;
    
    

    STEP4: 停止MySQL服务,重新正常启动

    
    ps -ef | grep -v 'grep' | grep 'mysqld' | awk '{print $2}' | xargs kill -9
    /export/servers/mysql/bin/mysqld_safe --defaults-file=/export/servers/mysql/etc/my.cnf &
    
    

    相关文章

      网友评论

          本文标题:MySQL忘记管理员密码

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