How to change password after MySQL database forgot password

Source: Internet
Author: User

When we forget the MySQL database password we will not be able to enter the database, and can not change the password, then how to change the password, here to teach you a simple commonly used to change the password way.

Method/Step
  1. 1

    Open the folder where Mysql.exe and Mysqld.exe are located, copy the path address

  2. 2

    Open the cmd command prompt and go to the folder where you mysql.exe the previous step.

  3. 3

    Enter the command mysqld--skip-grant-tables enter, at which point the user authentication of MySQL is skipped. Note After you enter this command, the command line cannot be manipulated, and you can open a new command line again. Note: End the Mysqld.exe process in Task Manager before entering this command to ensure that the MySQL server end is running.

  4. Then enter MySQL directly, do not need to bring any login parameters directly to enter the land database can be logged.

  5. Enter show databases; You can see all the database instructions successfully logged in.

  6. Where the MySQL library is where the user name is saved.   Input use MySQL; Select MySQL database.

  7. Show Tables View all the tables, you will find a user table, which is stored in the username, password, permissions and so on 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 (' 123456 ') where user= ' root ' and host= ' localhost ';

  10. View 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 in with the new password.

  12. Testing without a password to log in to MySQL, found or able to log on, but the database can only see the two database, the restart after the Skip password verification has been canceled.

  13. I'm in this place. The reason for not having a password after restarting the database is because there is an account in my database that does not have to be password-based.

    steps to read

How to change the password after the MySQL database forgets the password

Related Article

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.