Your password does not satisfy the current policy requirements解决办法

Posted 明天的明天 永远的永远 未知的一切 我与你一起承担 ??

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Your password does not satisfy the current policy requirements解决办法相关的知识,希望对你有一定的参考价值。

mysql5.7.x安装以后,想修改随机生成的密码为简单容易记忆的密码,如root,123456等,这时候通过修改密码的几种方式都不行,出现密码不符合当前安全策略要求。为了解决这种问题,可以修改几个值,他们是关于密码验证的设置。

我们通过随机生成的密码,登录数据库,查看密码验证相关变量:
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.00 sec)

得到这样的结果,密码长度要求8位,验证策略是MEDIUM,就是长度,数字,大小写,特殊字符都得验证,因此出现如此所示的错误,就很正常了。我们可以修改validate_password_policy=0,这样就是只检查长度。另外我们觉着8位太长了,我们可以改为4。这样可以设置root密码为root。

经过如下修改,再次验证。

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
 

 

mysql> show variables like \'validate_password%\';
+
| Variable_name                        | Value |
+
| validate_password_check_user_name    | OFF   |
| validate_password_dictionary_file    |       |
| validate_password_length             | 4     |
| 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.00 sec)

 

我们再次设置密码,就可以成功的设置root,123456等这样简单的密码了。

mysql> set password=password(\'root\');
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
mysql> exit
Bye
[root@buejee log]# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 9
Server version: 5.7.20 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.
 
mysql> 

 

补充几点:

1、修改密码的四种方式

a)shell命令行下mysqladmin -uroot -poldpassword password newpassword

b)sql命令行下 set password = password(newpassword);

c)sql命令行下 update user set authentication_string=password(newpassword) where user=\'root\';

d)sql命令行下 alter user root@\'localhost\' identified by \'newpassword\';//使用随机密码登录,如果要使用数据,查看数据库等操作时mysql会推荐这种写法改变密码。

2、密码策略的三个值分别代表的含义

a)LOW(0)只检查长度。

b)MEDIUM(1)检查长度,数字,大小写,特殊字符。

c)STRONG(2)检查长度,数字,大小写,特殊字符字典文件。

mysql修改密码Your password does not satisfy the current policy requirements

出现这个问题的原因是:密码过于简单。刚安装的mysql的密码默认强度是最高的,如果想要设置简单的密码就要修改validate_password_policy的值,

validate_password_policy有以下取值:

 

PolicyTests 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、先登入到mysql

2、设置安全级别

3、默认密码长度为8,可以设置为其它值,最小4位

4、设置新密码,刚安装完的mysql必须设置新密码(应该是从5.5版本开始)

 

以上是关于Your password does not satisfy the current policy requirements解决办法的主要内容,如果未能解决你的问题,请参考以下文章

Your password does not satisfy the current policy requirements解决办法

mysql5.7 Your password does not satisfy the current policy requirements问题解决

Linux MySQL8 Unknown system variable 'validate_password_policy'Your password does not satis

Linux MySQL8 Unknown system variable 'validate_password_policy'Your password does not satis

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements