First, when you first login, change password for the root account:
vim /etc/my.cnf
Add at the end of Skip -grant -tables, save.
service mysqld restart
When log in again, no password verification:
mysql -uroot
mysql> use mysql
mysql> update user set authentication_string=password('HEpan693640.') where user='root';
mysql> flush privileges;
mysql> quit
Modify the above code is equivalent to when mysql installed initializing passwords into what we modify the password. So the next time a normal login system mysql database or to modify the original password you out.
vim /etc/my.cnf, comments, or delete Skip -grant -tables
service mysqld restart
Account password again:
mysql -uroot -pHEpan693640.
At this point you will be prompted to change your password, and you must use the ALTER USER modify, in addition, can not perform any other statements:
mysql> alter user 'root'@'localhost' identified by 'root';
At this point the system error: ERROR 1819 (HY000): Your password does not Satisfy requirements at The Current Policy
Reason: The password policy is too restrictive.
Set the password more complex, meet the password policy: mysql> alter user 'root' @ 'localhost' identified by 'Root1 @ 345';
Then, you can perform the other statements.
I also want to modify the password pretty simple, so you need to modify password policy:
Modify password policy:
mysql> set global validate_password_length=1;
mysql> set global validate_password_mixed_case_count=0;
mysql> set global validate_password_number_count=0;
mysql> set global validate_password_policy='LOW';
mysql> set global validate_password_special_char_count=0;
After modifying the password policy as follows:
Then execute the method can alter user, or otherwise modify the password again.
Second, other times to change the password method:
1、mysql> alter user 'root'@'localhost' identified by 'root';
2、mysql> set password=password('root');
3, [root @ node03 ~] # / usr / bin / mysql_secure_installation, then go down the prompts.
4, vim /etc/my.cnf added at the end validate-password = OFF, password authentication may be skipped.