1. First enter "service mysqld status" To view the current MySQL service status, showing that the MYSQLD service is running.
2. Enter the "killall-term mysqld" command to stop all mysqld processes.
3. Enter the "Service mysqld Stop" command to stop the MYSQLD service.
4. Enter "Mysqld_safe--skip-grant-tables &" command to enter MySQL Safe mode without password.
5. Enter "Mysql-u root" and press ENTER.
6. Enter "use MySQL;" Mount the database.
Note: Do not forget to enter a semicolon (;) at the end.
7. Enter "Update user set Password=password (" Redhat ") where user= ' root ' to change the root password to new9ssw0rd.
8. Enter "flush privileges;" Update permissions.
9. Enter "Quit" and press ENTER to exit.
Note: You do not need to enter a semicolon here.
10. Enter "Service mysqld restart" to restart the mysqld services.
11. Enter "Mysql-u root-p" and press ENTER to prompt for the password.
12. Enter the new password Redhat and press ENTER to indicate that you have successfully logged in.
How to reset the MySQL root (root) password under Redhat Linux (CentOS)