The approximate steps are as follows:
1: Stop MySQL server
2: Start MySQL with Mysqld_safe
3: Change root password
4: Exit, restart MySQL server
Step One: There are several ways to stop the MySQL server:
1. Stop MySQL with service mysqld stop
2. If not, use the KILL command directly to stop the MYQLD service, first need to use ps aux | grep mysql to view the MySQL-related process PID, (using PS aux can see the PID is the second column), and then use the kill-9 XXXX in turn kill
Step two: Start MySQL with Mysqld_safe
Use the following command to start MySQL:
Mysqld_safe--skip-grant-tables &
Until you see the following prompt, it indicates a successful start
Starting mysqld daemon with databases From/var/lib/mysql
Log in to MySQL with the root account
Mysql-u Root
Step Three: Modify the MySQL root password
mysql> use MySQL; mysql> Update user Set Password=password ("New-root-password") where user= ' ROOT ';mysql> flush Privileges;mysql > quit;
Step four: restart MySQL
MySQL Reset Root Password