1 mysql 報錯解決mysql> grant all on *.* to "dba"@"%" identified by "mysql123";ERROR 1819 (HY000): Your password does not satisfy the current policy requir ...
1 mysql 報錯解決
mysql> grant all on *.* to "dba"@"%" identified by "mysql123";
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
報錯原因:
原來MySQL5.6.6版本之後增加了密碼強度驗證插件validate_password,相關參數設置的較為嚴格。
使用了該插件會檢查設置的密碼是否符合當前設置的強度規則,若不滿足則拒絕設置。影響的語句和函數有:create user,grant,set password,password(),old password。
解決:
1) 查看mysql全局參數配置
該問題其實與mysql的validate_password_policy的值有關。
查看一下msyql密碼相關的幾個全局參數:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.02 sec)
2)參數解釋
validate_password_dictionary_file
插件用於驗證密碼強度的字典文件路徑。
validate_password_length
密碼最小長度,參數預設為8,它有最小值的限制,最小值為:validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
validate_password_mixed_case_count
密碼至少要包含的小寫字母個數和大寫字母個數。
validate_password_number_count
密碼至少要包含的數字個數。
validate_password_policy
密碼強度檢查等級,0/LOW、1/MEDIUM、2/STRONG。有以下取值:
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,所以剛開始設置的密碼必須符合長度,且必須含有數字,小寫或大寫字母,特殊字元。
validate_password_special_char_count
密碼至少要包含的特殊字元數。
3) 修改密碼策略為低
mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.01 sec)
4 ) 修改密碼最小長度
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)