Change Password newspaper ERROR 1819 (HY000) Linux environment: Your password does not satisfy the current policy requirements

For added security, MySQL5.7 randomly generate a password for the root user, the error log, with regard to the location of the error log, if the installation of RPM packages, the default is /var/log/mysqld.log.

Generally provided by log_error

mysql> select @@log_error;
+---------------------+
| @@log_error         |
+---------------------+
| /var/log/mysqld.log |
+---------------------+
row in set (0.00 sec)
MySQL can get a temporary password by # grep "password" /var/log/mysqld.log command
2016-01-19T05:16:36.218234Z 1 [Note] A temporary password is generated for root@localhost: waQ,qR%be2(5

The password used to log in to the server, the password must be changed immediately, otherwise it will report the following error:

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

If only modified to a simple password, it will be reported the following error:

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

This is actually related to the value of validate_password_policy.

validate_password_policy have the following values:

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

The default is 1, that is, MEDIUM, so just start setting password must meet the length and must contain numbers, uppercase or lowercase letters, special characters.

Sometimes, just to test myself, do not want to set a password so complicated, say, I just want to set the root password is 123456.

We must modify two global parameters:

First, change the value of the parameter validate_password_policy

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

Thus, based on the criteria for judging the password the length of the password. This is determined by the validate_password_length parameters.

 

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

validate_password_length parameter defaults to 8, which has a minimum limit, minimum value:

validate_password_number_count
+ validate_password_special_char_count
+ (2 * validate_password_mixed_case_count)

Wherein, validate_password_number_count specifies the length of the data code, validate_password_special_char_count specifies the length of the special characters in the password, validate_password_mixed_case_count letter size specifies the length of the password.

These parameters, default values ​​are 1, so validate_password_length a minimum of 4, if you explicitly specify a value of less than 4 validate_password_length, despite not being given, but the value will be set validate_password_length 4. As follows:

 

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)

If modified validate_password_number_count, validate_password_special_char_count, validate_password_mixed_case_count any value, then the dynamic validate_password_length modified.

 

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)

Of course, the premise is validate_password plug must be installed, MySQL5.7 is installed by default.

So how do you verify validate_password plug-in is installed it? By viewing the following parameters, if not installed, the output will be empty.

 

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)

 

Original Address:  https://www.cnblogs.com/ivictor/p/5142809.html

Guess you like

Origin blog.csdn.net/w893932747/article/details/91866659