1. 程式人生 > >【Mysql 5.7】ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

【Mysql 5.7】ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

1、通過mysql -uroot -p,輸入密碼登入後,必須馬上修改密碼,否則會報錯

2、將密碼修改為123456,依然報錯

 

這和mysql 5.7的密碼策略(validate_password_policy)有關,validate_password_policy可以取如下值:

預設為1即MEDIUM,包含長度、數字、英文大小寫、特殊字元校驗。長度由validate_password_length配置,預設為8.

3、在/etc/my.cnf配置檔案中增加

4、修改密碼為12345678,成功

 

 5、檢視當前密碼策略

 1
mysql> show VARIABLES like "%password%" 2 -> ; 3 +---------------------------------------+-------+ 4 | Variable_name | Value | 5 +---------------------------------------+-------+ 6 | default_password_lifetime | 0 | 7 | disconnect_on_expired_password | ON | 8
| log_builtin_as_identified_by_password | OFF | 9 | mysql_native_password_proxy_users | OFF | 10 | old_passwords | 0 | 11 | report_password | | 12 | sha256_password_proxy_users | OFF | 13 | validate_password_check_user_name | OFF | 14
| validate_password_dictionary_file | | 15 | validate_password_length | 8 | 16 | validate_password_mixed_case_count | 1 | 17 | validate_password_number_count | 1 | 18 | validate_password_policy | LOW | 19 | validate_password_special_char_count | 1 | 20 +---------------------------------------+-------+ 21 14 rows in set (0.01 sec)
default_password_lifetime:密碼過期時間(天數),0表示永不過期
validate_password_length:密碼長度,預設為8
validate_password_policy:密碼複雜度