Home  >  Article  >  Database  >  Detailed explanation of how to reset the MySQL root (Root) password under Linux (CentOS) (picture and text)

Detailed explanation of how to reset the MySQL root (Root) password under Linux (CentOS) (picture and text)

黄舟
黄舟Original
2017-03-17 13:48:581125browse

This article mainly introduces the detailed explanation on how to reset the MySQL root (Root) password under Linux(CentOS). It has certain reference value for those who are interested. You can refer to it.

This example uses the example of modifying MySQL5.1.73 under CentOS6.6.

1. First enter "service mysqld status" to view the current mysql service status. The following figure shows 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 the "mysqld_safe --skip-grant-tables &" command to enter MySQLsafe mode without a password.

5. Enter "mysql -u root" and press Enter.

#6. Enter "use mysql;" to mount the database.

Note: Don’t forget to enter the semicolon (;) at the end.

#7. Enter "update user set password=password("New9ssw0rd") where user='root';" to change the Root password to New9ssw0rd.

#8. Enter "flush privileges;" to update permissions.

#9. Enter “quit” and press Enter to exit.

Note: No semicolon is required here.

#10. Enter "service mysqld restart" to restart the mysqld service.

11. Enter "mysql -u root -p" and press Enter to prompt for the password.

12. Enter the new password New9ssw0rd and press Enter. It will prompt that you have successfully logged in.


The above is the detailed content of Detailed explanation of how to reset the MySQL root (Root) password under Linux (CentOS) (picture and text). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn