mysql5.7设置简单密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

现象:设置简单密码会报错:

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。

解决:

该问题其实与mysql的validate_password_policy的值有关,查看一下msyql密码相关的几个全局参数:

**[sql]** [view plain](http://blog.csdn.net/youshounianhua123/article/details/79606581# "view plain")[copy](http://blog.csdn.net/youshounianhua123/article/details/79606581# "copy")

<embed id="ZeroClipboardMovie_1" src="https://csdnimg.cn/public/highlighter/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=16&amp;height=16" wmode="transparent" style="animation-duration: 0.001s; animation-name: playerInserted; box-sizing: border-box;"> 

1.  mysql> select @@validate_password_policy;    
2.  +----------------------------+    
3.  | @@validate_password_policy |    
4.  +----------------------------+    
5.  | MEDIUM                     |    
6.  +----------------------------+    
7.  1 row in set (0.00 sec)    

10.  mysql> SHOW VARIABLES LIKE 'validate_password%';    
11.  +--------------------------------------+--------+    
12.  | Variable_name                        | Value  |    
13.  +--------------------------------------+--------+    
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             | MEDIUM |    
19.  | validate_password_special_char_count | 1      |    
20.  +--------------------------------------+--------+    
21.  6 rows in set (0.08 sec)  

参数解释

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。有以下取值:
<u style=”box-sizing: border-box;”>Policy Tests Performed </u>
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

密码至少要包含的特殊字符数。

修改:

**[html]** [view plain](http://blog.csdn.net/youshounianhua123/article/details/79606581# "view plain")[copy](http://blog.csdn.net/youshounianhua123/article/details/79606581# "copy")

<embed id="ZeroClipboardMovie_2" src="https://csdnimg.cn/public/highlighter/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="16" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=16&amp;height=16" wmode="transparent" style="animation-duration: 0.001s; animation-name: playerInserted; box-sizing: border-box;"> 

1.  mysql> set global validate_password_policy=0;    
2.  Query OK, 0 rows affected (0.05 sec)    

4.  mysql>     
5.  mysql>     
6.  mysql> set global validate_password_mixed_case_count=0;    
7.  Query OK, 0 rows affected (0.00 sec)    

9.  mysql> set global validate_password_number_count=3;    
10.  Query OK, 0 rows affected (0.00 sec)    

12.  mysql> set global validate_password_special_char_count=0;    
13.  Query OK, 0 rows affected (0.00 sec)    

15.  mysql> set global validate_password_length=3;    
16.  Query OK, 0 rows affected (0.00 sec)    

18.  mysql> SHOW VARIABLES LIKE 'validate_password%';    
19.  +--------------------------------------+-------+    
20.  | Variable_name                        | Value |    
21.  +--------------------------------------+-------+    
22.  | validate_password_dictionary_file    |       |    
23.  | validate_password_length             | 3     |    
24.  | validate_password_mixed_case_count   | 0     |    
25.  | validate_password_number_count       | 3     |    
26.  | validate_password_policy             | LOW   |    
27.  | validate_password_special_char_count | 0     |    
28.  +--------------------------------------+-------+    
29.  6 rows in set (0.00 sec)    

原文链接:http://blog.csdn.net/kuluzs/article/details/51924374

    原文作者:风再起时yhl
    原文地址: https://www.jianshu.com/p/b4848a72e2a4
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞