ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
MySQL5.7爲root用戶隨機生成了一個密碼,在error log中,關於error log的位置,默認是/var/log/mysqld.log
獲取隨機密碼:
grep “password” /var/log/mysqld.log
[root@instance-2lfpjykx ~]# mysql -uroot -p
輸入隨機密碼登入mysql
修改用戶密碼
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxx';
出現錯誤:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
這個與validate_password_policy的值有關,修改爲一個簡單的密碼,會報以上錯誤。
Policy | Tests Performed |
---|---|
0 or LOW | Length |
1 or MEDIUM | Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG | Length; numeric, lowercase/uppercase, and special characters;dictionary file |
默認是1,即MEDIUM,所以剛開始設置的密碼必須符合長度,且必須含有數字,小寫或大寫字母,特殊字符。
不想密碼設置得那麼複雜,如只想設置root的密碼爲123456
設置
set global validate_password_policy=0;
現在密碼只需符合長度限制
validate_password_length參數默認爲8,它有最小值的限制,最小值爲:
Length = validate_password_number_count+validate_password_special_char_count+ (2 * validate_password_mixed_case_count)
其中,validate_password_number_count指定了密碼中數據的長度,validate_password_special_char_count指定了密碼中特殊字符的長度,validate_password_mixed_case_count指定了密碼中大小字母的長度。
這些參數,默認值均爲1,所以validate_password_length最小值爲4,如果你顯性指定validate_password_length的值小於4,儘管不會報錯,但validate_password_length的值將設爲4。
mysql> set global validate_password_length = 6;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 6 |
+----------------------------+