How to modify the mysql database password and forget the mysql Database Password

Source: Internet
Author: User

How to modify the mysql database password and forget the mysql Database Password

Because the database has not been used for a long time, or you forget the database password after changing the password, you cannot enter the database normally or change the password. There is a simple common password change method:

1. First, find and open the folder where mysql.exeand mysqld.exe are located (under the bin folder of your installed Mysql) and copy the path.

2.windows+ropen the logging command to enter the folder where mysql.exe is located.

3. Enter the command mysqld -- skip-grant-tables and press Enter. mysql user authentication is skipped. Note that after you enter this command, the command line cannot be operated. In this case, you can open a new command line. Note: before entering this command, run the mysqld.exe process in the task manager to ensure that the mysql server is running.

 

4. Then, enter mysql directly. you can log on to the database without entering any logon parameters.

5. Enter show databases. All databases are successfully logged on.

6. the mysql database is the place where the user name is saved. Enter use mysql and select mysql database.

7. view all tables in show tables and you will find a user table, which stores the user name, password, permissions, and other account information.

8. Enter select user, host, password from user; To view account information.

 

9. Change the root password, enter update user set password = password ('root') where user = 'root' and host = 'localhost'; change the password to root here.

10. view the account information again. select user, host, password from user; you can see that the password has been modified.

11. Exit the command line, restart the mysql database, and try to log on with the new password.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.