Steps to change password for MySQL8.0 in LINUX system

1. Program error

Your password does not satisfy the current policy requirements

        Translation: Your password does not comply with the current policy requirements

You must reset your password using ALTER USER statement before executing this statement.

         Translation: Before executing this statement, the password must be reset using the ALTER USER statement.

2. Project background        

        After installing MySQL8.0 in the LINUX system, use  the cat /var/log/mysqld.log command to view the output log of mysql. You can see that after installing MySQL8.0, my default initial password here is k5yV0NyClY,J

        

        For our daily study, this password is too difficult to remember, so we need to change a simple password that we remember.

3. Error analysis

        After consulting a lot of information and tutorials, the steps to change the password for MySQL version 5.0 are ( semicolons are essential!!! )

set global validate_password_policy=LOW; Set the password level to be lower, making it easier for us to set a simple password
set global validate_password_length=6 (variable) ; Set the minimum password length

set password=password('************'); set password

        For MySQL8.0 version, we have to set the password first, and then set the password level and length . It must be noted here that the statement  set global validate_password used to modify the password level and minimum length in version MySQL 8.0 is changed from the previous '_' to '.' .

alter user 'root'@'localhost' identified with mysql_native_password by '****'; change password

set global validate_password . policy=0; Set the password level to be lower, making it easier for us to set a simple password
set global validate_password . length=6 (variable) ; Set the minimum password length

        If the password level and length are set first like the MySQL 5.0 version, the error  You must reset your password using ALTER USER statement before executing this statement will be reported. Prompt that we must first use the ALTER USER statement to reset the password. But if we directly follow his prompts to set the password now, we will get the error Your password does not satisfy the current policy requirements, prompting us that the password does not satisfy the current policy requirements, that is, the password is too simple.

4. Error resolution (valid for personal testing)

        Since it prompts us that the password does not meet the current policy requirements , let us first change the password according to his policy. Here I first change the password to the default password he gave me and change one digit, which is the default initial password I mentioned above. For k5yV0NyClY,J , I changed the last 'J' to 'G' . It shows that the modification was successful.

         Then set the password level and minimum length.

Code:

(1) Change the password according to the policy

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'k5yV0NyClY,G';

(2) Change password level

set global validate_password.policy=0;
(3) Modify the minimum password length

set global validate_password.length=6;

(4) Change the password you want

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '****';

        

        Finally solved successfully! ! !

Guess you like

Origin blog.csdn.net/weixin_64709241/article/details/129499385