How MySQL resets the root user password

Source: Internet
Author: User
Tags mysql command line

This tutorial is intended for WebEx VPS and cloud host products with Win2003, WinXP operating systems.

What if the administrator forgets the MySQL password? Repeatedly entered the password, still prompt error, the site does not work properly, the database can not be managed, the administrator is helpless.

When the Web program or MySQL management software connects to the MySQL server with a bad password, "1045-access denied for user ' root ' @ ' localhost ' (using password:yes)" error message appears, such as:

When you confirm that you have forgotten your MySQL password, you can reset the root user password through the following scenarios. Double-click Open C:\Program files\mysql\mysql Server 5.1\my.ini file, such as:

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:

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:

MySQL does not require a password to log in to the database. Click on the bottom left corner "start", "All Programs", "MySQL", "MySQL Server 5.1", "MySQL command line Client" To open the MySQL console. The "Enter Password:" Prompt appears in the window and directly press ENTER to log in to the MySQL console.

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.

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:

After clicking "OK", we find that we can connect to MySQL database. Such as:

This completes the root user password reset for MySQL. Thank you for watching.


There may also be many third-party tools connected to the MySQL database that require the JDBC jar to now provide the official jar.

MySQL Connector download package

How MySQL resets the root user 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.