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

为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log。

一般可通过log_error设置

mysql> select @@log_error;
+---------------------+
| @@log_error         |
+---------------------+
| /var/log/mysqld.log |
+---------------------+
1 row in set (0.00 sec)

可通过# grep "password" /var/log/mysqld.log 命令获取MySQL的临时密码

2016-01-19T05:16:36.218234Z 1 [Note] A temporary password is generated for [email protected]: waQ,qR%be2(5

用该密码登录到服务端后,必须马上修改密码,不然会报如下错误:

mysql> select user();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

如果只是修改为一个简单的密码,会报以下错误:

mysql>  ALTER USER USER() IDENTIFIED BY ‘12345678‘;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

这个其实与validate_password_policy的值有关。

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

有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。

必须修改两个全局参数:

首先,修改validate_password_policy参数的值

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

这样,判断密码的标准就基于密码的长度了。这个由validate_password_length参数来决定。

mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
|                          8 |
+----------------------------+
1 row in set (0.00 sec)

validate_password_length参数默认为8,它有最小值的限制,最小值为:

validate_password_number_count
+ validate_password_special_char_count
+ (2 * validate_password_mixed_case_count)

其中,validate_password_number_count指定了密码中数据的长度,validate_password_special_char_count指定了密码中特殊字符的长度,validate_password_mixed_case_count指定了密码中大小字母的长度。

这些参数,默认值均为1,所以validate_password_length最小值为4,如果你显性指定validate_password_length的值小于4,尽管不会报错,但validate_password_length的值将设为4。如下所示:

mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
|                          8 |
+----------------------------+
1 row in set (0.00 sec)

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

mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
|                          4 |
+----------------------------+
1 row in set (0.00 sec)

如果修改了validate_password_number_count,validate_password_special_char_count,validate_password_mixed_case_count中任何一个值,则validate_password_length将进行动态修改。

mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
|                          4 |
+----------------------------+
1 row in set (0.00 sec)

mysql> select @@validate_password_mixed_case_count;
+--------------------------------------+
| @@validate_password_mixed_case_count |
+--------------------------------------+
|                                    1 |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> set global validate_password_mixed_case_count=2;
Query OK, 0 rows affected (0.00 sec)

mysql> select @@validate_password_mixed_case_count;
+--------------------------------------+
| @@validate_password_mixed_case_count |
+--------------------------------------+
|                                    2 |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
|                          6 |
+----------------------------+
1 row in set (0.00 sec)

当然,前提是validate_password插件必须已经安装,MySQL5.7是默认安装的。

那么如何验证validate_password插件是否安装呢?可通过查看以下参数,如果没有安装,则输出将为空。

mysql> SHOW VARIABLES LIKE ‘validate_password%‘;
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file    |       |
| validate_password_length             | 6     |
| validate_password_mixed_case_count   | 2     |
| validate_password_number_count       | 1     |
| validate_password_policy             | LOW   |
| validate_password_special_char_count | 1     |
+--------------------------------------+-------+
6 rows in set (0.00 sec)

时间: 2024-10-05 10:41:45

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements的相关文章

linux下mysql操作ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

关于这个问题是在 < 基于MySQL Yum存储库在Linux-7.2上安装MySQL-5.7.21数据库服务(实战篇) > 时遇到的问题,这是 mysql 初始化时,使用临时密码,修改自定义密码时,由于自定义密码比较简单,就出现了不符合密码策略的问题. 密码策略问题异常信息:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 如下图: 解决办法: 1.查看 mysql 初始的密码

mysql 修改密码提示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.7 以后数据库安全密码策略需要更改,不能使用简单密码. 如图: ALTER USER 'root'@'localhost' IDENTIFIED BY 'huazai12345'; 解决办法: 1.查询安全策略 输入语句 “ SHOW VARIABLES LIKE 'validate

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

出现这个问题的原因是:密码过于简单.刚安装的mysql的密码默认强度是最高的,如果想要设置简单的密码就要修改validate_password_policy的值, validate_password_policy有以下取值: Policy Tests Performed 0 or LOW Length 1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters 2 or STRONG Length; numer

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

安装mysql5.7rpm包,在更改密码的时候,提示错误 这是由于Mysql5.7默认对于密码的要求强度较高,设置的密码过于简单不予通过.要解决这个问题,涉及到的参数有validate_password_policy和validate_password_length. validate_password_policy有以下取值: Policy Tests Performed 0 or LOW Length 1 or MEDIUM Length; numeric, lowercase/upperc

mysql5.7设置简单密码报错ERROR 1819 (HY000): Your password

[问题] 有时候,只是为了自己测试,不想密码设置得那么复杂,譬如只想设置root的密码为123456. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456'); 但是会报错: mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');ERROR 1819 (HY000): Your password does not satisfy the current policy re

[mysql] ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.

今天安装mysql遇到这样一个问题: ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords. 意思就是密码过期了. 修改密码了: mysql> SET PASSWORD = PASSWORD('abc'); ERROR 1819 (HY000): Your password does not satisfy

mysql5.7密码过期ERROR 1862 (HY000): Your password has expired. To log in you must change

环境: ubuntu14.04  mysql5.7 一.mysql5.7 密码过期问题 报错: ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords. 翻译: 错误1862(HY000):你的密码已经过期.登录必须改变它使用一个客户端,支持过期的密码. 解决方法: 1. 用忽略授权表的方法进入mysql  

mysql 5.7密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

1.重新修改密码,语句如下: mysql> alter user 'root'@'localhost' identified by '123'; Query OK, 0 rows affected (0.00 sec) 2.如果修改过程出现错误(如下),转后面操作: mysql> alter user 'root'@'localhost' identified by '123'; ERROR 1819 (HY000): Your password does not satisfy the cu

ERROR 1372 (HY000): Password hash should be a 41-d

MySql创建用户(包括密码)时,会提示ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number: 问题原因:你输入的密码是明文.不允许这么输入. 解决办法:用select password('你想输入的密码');查询出你的密码对应的字符串, 然后用这个字符串在创建用户命令中替换你的密码.