Method One: Use the Set password command
First, log in to MySQL
?
Then execute the Set password command
?
1 |
set password for [email protected] = password ( ‘654321‘ ); |
In the example above, change the root password to 654321
Method Two: Use Mysqladmin
Format: Mysqladmin-u username-P Old password password new password
?
1 |
mysqladmin -uroot -p123456 password "654321" |
In the example above, change the root password from 123456 to 654321
Method Three: Change the user table for MySQL
First, log in to MySQL
?
Then manipulate the user table of the MySQL library to update
?
123 |
mysql> use MySQL; mysql> update user set password = password ( ' 654321 ' where user = ' root ' and host= ' localhost ' mysql> flush privileges |
Method Four: In case of forgetting the password
First stop the MySQL service
?
Start MySQL in a way that bypasses authorization
?
1 |
mysqld_safe --skip-grant-tables & |
Log in as root user MySQL
?
Manipulate the user table of the MySQL library to update
?
1234 |
mysql> use mysql; mysql> update user set password = password ( ‘654321‘ ) where user = ‘root‘ and host= ‘localhost‘ ; mysql> flush privileges ; mysql> quit |
Restart MySQL Service
?
Linux forgot password/change password