linux under mysql5.7 and below change the root user password records

1, mysql 5.7 Change password record:
After the application Ali cloud account comes with mysql database, but mysql -u root -p can not directly log in, then change your password, recorded as follows:

1) vi /etc/my.cnf
2) increase at a certain position [mysqld] of the following: skip-grant-tables, then: wq to save and exit
3) command in the / usr / local / mysql / bin directory: / mysql -u root -p, then enter twice to enter the MySQL
. 4) Run:
use MySQL
the SET SQL_SAFE_UPDATES = 0
. 5) Update the mysql.user SET authentication_string = password ( 'the root') = the User WHERE 'the root';
. 6) the flush privileges;
. 7) Run: = SQL_SAFE_UPDATES the SET. 1
. 8) /etc/my.cnf VI, delete the row skip-grant-tables
. 9) the restart-Service mysqld
10) performed under / usr / local / mysql / bin directory command: ./mysql -u root -p then enter the new password: root to enter mysql
2, version 5.6 mysql change password:
mysql5.7 the relatively simple change password version
1) after completion of installation configuration, the following command to execute mysql
mysql -u root -p, enter twice to enter MySQL
2) Change password: update user set password = password ( 'root') where User = 'root';
3)flush privileges ;

Guess you like

Origin blog.51cto.com/14447470/2420467