How MySQL resets the root user password "pro-Test available"

Source: Internet
Author: User

1. Error

2. When you are sure that you have forgotten your MySQL password, you can reset the root user password by using the following scenario. Double-click Open C:\Program files\mysql\mysql Server 5.1\my.ini file, such as:

3. Click "Edit" at the top of the "Notepad" software, select "Find", enter [mysqld] at "Find what", and click "Find Next", it will automatically go to the [mysqld] Field row. Add a line skip-grant-tables below and save it, such as: "mysql_5.6 no My.ini file, you can copy the My-default.ini file to My.ini and add Skip-grant-tables"

4. Click "Start" in the lower left corner, "Administrative Tools", "services". Right-click on the "MySQL" service in the list of services and select "Restart", such as:

5. Open MySQL, you can cmd-mysql enter;

Enter use MySQL; press ENTER, the database changed prompt appears. Then enter update user set Password=password (' New password ') WHERE user= ' root '; press ENTER. For example: You need to set the password is mysql789, then you need to enter the update user set Password=password (' mysql789 ') WHERE user= ' root ', if you are concerned about the input error, you can directly copy the content, right mouse button in the point to the console blank, select "Paste", and then press ENTER to run, there is a prompt "Query OK, 2 rows Affected (0.00 sec) rows Matched:2 changed:2 warnings:0". Such as.

6. Enter the flush privileges; press ENTER, and the "Query OK, 0 rows Affected (0.00 sec)" prompt appears. Remove the skip-grant-tables from the line below the [mysqld] field in My.ini and restart the MySQL service again. At this point, connect the database with the new password mysql789, such as:

Done!!!

How MySQL resets the root user password "pro-Test available"

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.