The first step
Check to make sure the MySQL is installed
# rpm-qa|grep-i MySQL
The execution effect is as follows
Step Two
To restart MySQL:
#/etc/init.d/mysqld
As follows
Because I have already opened, so with restart restart, if you do not open, directly with start
#/etc/init.d/mysqld Restart
The meaning of this sentence is to open the MySQL backend service
The execution effect is as follows
Step Three
View MySQL process and installation directory
# ps-ef|grep-i MySQL
As follows
You can see where the Mysqld_safe is installed (the blue part above):/usr/bin/
Then execute the command to stop MySQL:
/etc/init.d/mysqld stop
Fourth Step
To start MySQL in a safe manner:
#/usr/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &
Then execute the following statement:
#/usr/bin/mysql-u Root MySQL
Note: MySQL is the same as the Mysql_safe directory:/usr/bin/, this is through the "Ps-ef | grep-i MySQL "command to get.
When the "mysql>" prompt appears, enter:
mysql> Update user Set password = password (' Hanhan ') where user = ' root ';
Enter after the execution (refresh the MySQL system permissions related tables):
mysql> flush Privileges;
Then execute exit exit:
Mysql> exit;
After exiting, use the following command to log in to MySQL and try to succeed:
#mysql-U root-p
Enter password as prompted: root
Of course you can also follow this procedure to reset the password to any other string
Linux CentOS reset MySQL tutorial