MySQL5.6.6版本以後增長了密碼強度驗證插件validate_password,相關參數設置的較爲嚴格。mysql
使用了該插件會檢查設置的密碼是否符合當前設置的強度規則,若不知足則拒絕設置。影響的語句和函數有:create user,grant,set password,password(),old password。sql
【問題】ide
mysql執行受權設置密碼報錯:函數
mysql> grant all on jumpserver.* to 'jumpserver'@'%' identified by 'weakPassword'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
【解決】
1) 查看mysql全局參數配置ui
該問題其實與mysql的validate_password_policy的值有關。
查看一下msyql密碼相關的幾個全局參數:spa
mysql> select @@validate_password_policy; +----------------------------+ | @@validate_password_policy | +----------------------------+ | MEDIUM | +----------------------------+ 1 row in set (0.00 sec) mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | 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 | +--------------------------------------+--------+ 6 rows in set (0.08 sec)
2)參數解釋插件
validate_password_dictionary_file
插件用於驗證密碼強度的字典文件路徑。code
validate_password_length
密碼最小長度,參數默認爲8,它有最小值的限制,最小值爲:validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)orm
validate_password_mixed_case_count
密碼至少要包含的小寫字母個數和大寫字母個數。server
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參數配置
mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.05 sec) mysql> mysql> mysql> set global validate_password_mixed_case_count=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_number_count=3; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_special_char_count=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=3; Query OK, 0 rows affected (0.00 sec) mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+-------+ | Variable_name | Value | +--------------------------------------+-------+ | validate_password_dictionary_file | | | validate_password_length | 3 | | validate_password_mixed_case_count | 0 | | validate_password_number_count | 3 | | validate_password_policy | LOW | | validate_password_special_char_count | 0 | +--------------------------------------+-------+ 6 rows in set (0.00 sec)
4)修改簡單密碼:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123'); Query OK, 0 rows affected, 1 warning (0.00 sec)