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)检查长度,数字,大小写,特殊字符字典文件。


  • 17
    点赞
  • 80
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值