As a beginner in MySQL, you might encounter an error message that reads “ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.” This error is not a bug, but a built-in security feature of MySQL that ensures users set strong passwords. This tutorial will guide you through understanding this error and how to fix it.
What Triggers the Error?
When setting up a password for the MySQL root user, you may be prompted to enable the VALIDATE PASSWORD component. If enabled, this component checks the strength of the password you provide. If your password is considered weak, you’ll encounter the error 1819.
For example, if you try to create a user with a weak password like this:
mysql> create user 'ostechnix'@'localhost' identified by 'mypassword';
You’ll see the error:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
This error will persist until you provide a password that meets the current password policy requirements or disable the VALIDATE PASSWORD component.
Understanding Password Validation Policy
MySQL enforces three levels of password validation policy when the VALIDATE PASSWORD plugin is enabled:
- LOW: Password must be at least 8 characters long.
- MEDIUM: Password must be at least 8 characters long, include numeric, mixed case, and special characters.
- STRONG: Password must be at least 8 characters long, include numeric, mixed case, special characters, and dictionary file.
To find the current password policy level, run the following command:
mysql> SHOW VARIABLES LIKE 'validate_password%';
The output will show the currently enforced password level. For instance, if the password level is Medium, your password should be 8 characters long and include a number, mixed case, and special characters.
How to Fix the Error
There are two main ways to fix the error 1819:
1. Change the Password to Meet the Policy
The first method is to set a password that meets the current password validation policy. For instance, if the policy is set to Medium, you could set a password like ‘Password123#@!’ which includes a number, lowercase, uppercase, and special characters.
2. Change the Password Validation Policy
The second method is to change the password validation policy to a lower level. To do this, run the following command from the MySQL prompt:
mysql> SET GLOBAL validate_password.policy=LOW;
Then, check if the password validation policy has been changed to low:
mysql> SHOW VARIABLES LIKE 'validate_password%';
Now, you can create a user with a weak password. To revert back to the MEDIUM level policy, simply run this command:
mysql> SET GLOBAL validate_password.policy=MEDIUM;
If the password policy doesn’t change, exit from the MySQL prompt and restart the MySQL service.
Disabling Password Validation Policy
If you wish to create users with weak passwords, you can disable the Validate Password component altogether and re-enable it back after creating the users. However, it’s not recommended to disable password policy or use weak passwords. Always use a strong password with more than 8 characters including a number, mixed case, and special characters.
Conclusion
In this tutorial, we’ve covered the common MySQL error 1819 and how to fix it. We’ve also discussed how to disable the password policy to allow weak passwords in some cases. However, it’s always recommended to use a strong password for better security. Happy learning!