Your password does not satisfy the current policy requirements

时间:2022-10-18 17:44:31

创建用户,做测试想设置一个简单的密码。报错:

Your password does not satisfy the current policy requirements

大概是MySQL5.7搞事情,默认安装了validate_password插件。

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 |
+--------------------------------------+--------+

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,所以密码必须符合长度,且必须含有数字、小写或大写字母和特殊字符。

综上我们强制把密码设置为123456,必须修改两个全局参数:

  1. 修改validate_password_policy参数的值,使判断密码的标准仅基于密码的长度。

    mysql> set global validate_password_policy=0;

  2. 修改validate_password_length,即密码长度参数的值。其默认为8,最小为4。

--查看密码长度
mysql> select @@validate_password_length; --修改密码长度
mysql> set global validate_password_length=6;

运行结果:

Your password does not satisfy the current policy requirements

参考文献:

http://www.linuxidc.com/Linux/2016-01/127831.htm