Just as what the title tells, this article aims to record how to reset the password of mysql for root user.
First, Due to there is going to be a period of time that the mysql is available without needing authentication, it will be very dangerous. So the best way to do such a risky thing is to plug the network cable out of the server to isolate it from the outer nerwork space.
datadir = /var/lib/mysql
save it and exit vi
And it will show this message:
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
# /usr/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 3.23.56 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> USE mysql ; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 mysql> flush privileges ; Query OK, 0 rows affected (0.01 sec) mysql> \q Bye
And all done.