美文网首页Linux科技
MySQL5.7重置密码

MySQL5.7重置密码

作者: Miracle001 | 来源:发表于2018-10-29 11:29 被阅读1次
    vim /etc/my.cnf
    增加一个选项  skip-grant-tables
    忽略密码登陆
    
    systemctl restart mysqld
    
    mysql -uroot -p
    update mysql.user set authentication_string=password('root') where user='root';
    flush privileges;
    
    vim /etc/my.cnf
    #skip-grant-tables  注释掉
    
    systemctl restart mysqld
    
    mysql -uroot -p
    输入密码
    show databases;
    报错:
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
    原因:密码设置过于简单
    
    想设置简单密码
    mysql> set global validate_password_policy=0;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> set global validate_password_length=1;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> set password=password('root');
    Query OK, 0 rows affected, 1 warning (0.08 sec)
    
    # 退出再登陆
    mysql -uroot -p
    输入密码
    
    
    参考文章
    https://www.linuxidc.com/Linux/2017-07/145607.htm
    
    

    相关文章

      网友评论

        本文标题:MySQL5.7重置密码

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