Problem:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'munna007###';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Solution:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+-------------------------------------------------+--------+
| Variable_name | Value |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0 |
| validate_password.check_user_name | ON |
| 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 |
+-------------------------------------------------+--------+
8 rows in set (0.01 sec)
As you can see, the currently enforced password level is Medium. So our password should be 8 characters long with a number, mixed case and special characters.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Munna007#';
Query OK, 0 rows affected (0.01 sec)
There is workaround to change the password with week password by changing the lower level or disabling password policy but I personally don’t recommend it. Here is the workaround.
Option 1:
mysql> SET GLOBAL validate_password.policy = 0;
Or
mysql> SET GLOBAL validate_password.policy=LOW;
mysql> SHOW VARIABLES LIKE 'validate_password%';
+-------------------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------------------+-------+
| validate_password.changed_characters_percentage | 0 |
| validate_password.check_user_name | ON |
| validate_password.dictionary_file | |
| validate_password.length | 8 |
| validate_password.mixed_case_count | 1 |
| validate_password.number_count | 1 |
| validate_password.policy | LOW |
| validate_password.special_char_count | 1 |
+-------------------------------------------------+-------+
8 rows in set (0.00 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'munna007';
Query OK, 0 rows affected (0.01 sec)
To revert back to MEDIUM level policy, simply run this command from mysql prompt:
mysql> SET GLOBAL validate_password.policy=MEDIUM;
Option 2:
If you like to create users with weak password, simply disable the “Validate Password” component altogether and re-enable it back after creating the users.
mysql> UNINSTALL COMPONENT "file://component_validate_password";
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'maryam';
Query OK, 0 rows affected (0.01 sec)
mysql> INSTALL COMPONENT "file://component_validate_password";
Query OK, 0 rows affected (0.00 sec)