【question】
Sometimes, just to test it yourself, I don’t want the password to be so complicated, for example, I just want to set the password of root to 123456.
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
But there will be an error:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
【reason】
It turns out that after the MySQL 5.6.6 version, the password strength verification plug-in validate_password has been added, and the relevant parameters are set relatively strictly.
Using this plug-in will check whether the set password meets the current set strength rules, and if it is not satisfied, the setting will be rejected. The statements and functions that are affected are: create user, grant, set password, password(), old password.
【solve】
1) Check the mysql global parameter configuration
This problem is actually related to the value of mysql's validate_password_policy.
Check out several global parameters related to msyql password:
mysql> select @@validate_password_policy;
+----------------------------+
| @@validate_password_policy |
+----------------------------+
| MEDIUM |
+----------------------------+
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| 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 |
+--------------------------------------+--------+
6 rows in set (0.08 sec)
2) Parameter explanation
validate_password_dictionary_file
The plugin is used to verify the password strength of the dictionary file path.
validate_password_length
The minimum length of the password, the default parameter is 8, it has a minimum value limit, the minimum value is: validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
validate_password_mixed_case_count
The password must contain at least the number of lowercase letters and uppercase letters.
validate_password_number_count
The password must contain at least the number of numbers.
validate_password_policy
Password strength check level, 0/LOW, 1/MEDIUM, 2/STRONG. There are 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 the password you set at the beginning must meet the length and must contain numbers, lowercase or uppercase letters, and special characters.
validate_password_special_char_count
The password must contain at least the number of special characters.
3) Modify mysqlParameter configuration
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.05 sec)
mysql>
mysql>
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count | 0 |
| validate_password_number_count | 3 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 0 |
+--------------------------------------+-------+
6 rows in set (0.00 sec)
4) Modify the simple password:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
OK, perfect solution!