zoukankan      html  css  js  c++  java
  • mysql5.7初始化密码报错ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstateme

    1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码

    cat /var/log/mysqld.log | grep password
    或者:grep 'temporary password' /var/log/mysqld.lo



    2,然后执行 mysql -uroot -p ,输入上面的到的密码进入,用该密码登录后,必须马上修改新的密码,不然会报如下错误:

    mysql> use mysql;
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.


    3,如果你想要设置一个简单的测试密码的话,比如设置为sztx@2018,会提示这个错误,报错的意思就是你的密码不符合要求

    mysql> alter user 'root'@'localhost' identified by ‘sztx@2018';
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

    .
    这个其实与validate_password_policy的值有关。

    validate_password_policy有以下取值:
    这里写图片描述
    默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
    有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。
    必须修改两个全局参数:

    首先,修改validate_password_policy参数的值

    mysql> set global validate_password_policy=0;
    Query OK, 0 rows affected (0.00 sec)


    validate_password_length(密码长度)参数默认为8,我们修改为1

    mysql> set global validate_password_length=1;
    Query OK, 0 rows affected (0.00 sec)


    4,完成之后再次执行修改密码语句即可成功

    mysql> alter user 'root'@'localhost' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)

     

    mysql5.7初始化密码报错ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstateme

  • 相关阅读:
    Linux Shell脚本详细教程
    linux下错误代码E212: Can't open file for writing
    github仓库的基本使用-创建、上传文件、删除
    -bash: ifconfig: command not found解决办法
    Xshell能ping通但连不上CentOS 7
    devtools和vuex mutations
    Google Chrome谷歌浏览器安装devtools
    Vuex状态管理模式
    vue Promise all
    vue Promise链式调用
  • 原文地址:https://www.cnblogs.com/Crazy-Liu/p/10912599.html
Copyright © 2011-2022 走看看