Have you set the Password Validation setting to “Strong, Medium, or Low”? Read the steps to update the password policy in MySQL.
While working on my local environment, I have set the password validation policy to “high,” and because of that, I need to type a long password to access the MySQL database.
And I don’t like to enter a long password every time, so I decided to change the password validation to low or just simply remove the password validation mechanism from the system.
If you too want to remove or change the current password validation mechanism, then read the following steps.
Note: I know you are well aware of the consequences of doing this stuff on the production server, so please don’t replicate the process in the production environment.
Table of Contents
Steps to Remove the MySQL Password Validation
To remove the MySQL password validation, you need to first login to your MySQL with the privileges, and then you need to pass the query, which will remove the password validation that you have kept.
Enough talk; now let me show you how to remove the password validation mechanism in MySQL.
Remove Validate Password Component
Open your terminal window and login back to your MySQL server with the same long password.
$ sudo mysql -u root -p
Once you login to your MySQL environment, use the following command to remove the password validation component:
mysql> UNINSTALL COMPONENT 'file://component_validate_password';
Result of the above command:
After making these changes, you can now update your MySQL password by clicking here.
If you ever want to restore the Password Validation Policy to MySQL, then execute the below command:
mysql> INSTALL COMPONENT 'file://component_validate_password';
Set Validate Password Component to Low
Instead of removing the password component, you can also set the validation level to low, which will allow you to set a simple password for MySQL.
Before setting the password validation to low, let’s see the current password policy level by running the below command into the MySQL console:
mysql> SHOW VARIABLES LIKE 'validate_password%';
As you can see validate_password.policy value is “STRONG”.
Now let’s change the value to “LOW” by running the following command:
mysql> SET GLOBAL validate_password.policy=LOW;
If you want to verify the changes, then execute the SHOW VARIABLES LIKE 'validate_password%';
query.
As you can see, the above command only changes the password policy to low, not the password length, number_count, and specific_char_count.
I would not advise you to change this value, but if you want to, then run the following command one by one:
mysql> SET GLOBAL validate_password.length=4;
mysql> SET GLOBAL validate_password.mixed_case_count=0;
mysql> SET GLOBAL validate_password.number_count=0;
mysql> SET GLOBAL validate_password.special_char_count=0;
# To revert above changes
mysql> SET GLOBAL validate_password.length=8;
mysql> SET GLOBAL validate_password.mixed_case_count=1;
mysql> SET GLOBAL validate_password.number_count=1;
mysql> SET GLOBAL validate_password.special_char_count=1;
After making the following changes, you can now update your password by following the next method.
Change Password
If you try to change your password without running the above command, you will end up with “ERROR 1819 (HY000): Your password does not satisfy the current policy requirements”.
Also Read: How to Reset MySQL Root Password in Ubuntu and Fix Error 1045 (28000)
So first remove the password validation component, then change the password using the following ALTER USER
query:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
#OR
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'PASSWORD';
Once you get the “Query OK” message, you can login back to MySQL with the new password.
And with that output, your work is done, and mine too.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.