MySQL database forgot password

Source: Internet
Author: User

Recently in the management of a server, is the version of Windows Server 2012, originally wanted to connect the database, found that the password was set, and the previous management has run away, there is no way to change the password. The following is the process of modification and recording.

1. First check whether the MySQL database service is started, which can be found directly in the Server Manager's "services". If you start, close the service first, you can use the command line to close the command:

net stop MySQL

2. After the shutdown is complete, the command line window enters the bin directory under the MySQL installation location. If you forget to install the path, you can also find the service in the "services", double-click to see. After entering the bin directory, execute the following command in the command-line window:

Mysqld-nt--skip-grant-tables

This statement means that you can skip user authentication and enter Safe mode.

3. After completing the previous step, do not close the command line window. Reopen a new command-line window and execute the database connection command:

Mysql-u root-p

At this point you will find that you do not need a password or login successfully.

4. Execute the command to change the password:

Update mysql.user Set password = password ('XXXX'root;

5. Last update, Exit is OK.

mysql> flush Privileges;mysql> exit;

6. When you're done, restart the MySQL service. But sometimes the error "1067 cannot connect", which may be due to the 3306 port is occupied. Use the following command to view the process PID that occupies the port, usually mysqld.exe, and stop it.

Netstat–ano

MySQL database forgot 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.