1. Change the database configuration table

Mysql > start mysql with service mysqld restart mysql > start mysql with service mysqld restart mysql > uroot -p, enter directly to the database command line.

2. Change your password

MySQL > change password (‘ password ‘, ‘password’);

UPDATE user SET Password=PASSWORD('yourpassword') where USER='root';

Versions after 5.7 should use:

update mysql.user set authentication_string=password('yourpassword') where user='root';

or

UPDATE user SET authentication_string=PASSWORD('yourpassword') where USER='root';

3. Restart debugging

When you restart MySQL again, enter the command and an error occurs. ERROR 1820 (HY000): UNKNOWN ERROR 1820. ERROR 1819: mysql > alter password (s); mysql > alter password (s); The reason is that the password is too simple, you can change the password default rule.

set global validate_password_policy=0;
set global validate_password_length=4;
alter user user() identified by '123456';

4. Knowledge introduction

MySQL defaults to setting a password (policy = 1).



Medium, so the password must match the length (default is 8), and must contain numbers, lowercase or uppercase letters, and special characters.

MySQL > modify the validate_password_policy parameter. MySQL > modify the validate_password_policy parameter

Set global validate_password_policy=0 set global validate_password_policy=0

Select @@validate_password_length from @@validate_password_length from @@validate_password_length;

Set global validate_password_length=4; set global validate_password_length=4;

System used: CentOS 7.6