How to solve the problem that mysql forgets the root password in windows

Source: Internet
Author: User

A friend was in a hurry: mysql forgot the root password and asked me to help you. I found the information from the Internet because I have never been in touch with mysql.
I have already put it into practice! The mysql version is 5.1.
The following is the information about changing the mysql password found on the Internet:
References:
How to reset the Mysql Root Password in windows
Mysql changes password and forgets Password
1. First, check whether the mysql service is started. If it has been started, stop the service. Run the following command in the Start Menu:
Net stop mysql
Open the first cmd1 window, switch to the mysql bin directory, and run the following command:
Mysqld -- defaults-file = "C: \ Program Files \ MySQL Server 5.1 \ my. ini" -- console -- skip-grant-tables
Note:
This command skips the permission security check and enables the mysql service. When you connect to mysql, you do not need to enter the user password. The mysql service has been enabled!
This window is retained.
2. Open the second cmd2 window and connect to mysql:
Enter the following command:
Mysql-u root-p
Appears:
Enter password:
Press enter here without entering the password.
Then there will be information about successful logon,
Run the following command:
Show databases;
Run the following command to switch to the mysql database:
Use mysql;
Run the following command to change the root password:
UPDATE user SET Password = PASSWORD ('newpassword') where USER = 'root ';
Refresh permission:
Flush privileges;
Then exit and log on again:
Quit
Log On again:You can close the previous cmd1 window. Then start the service with net start mysql.
Mysql-u root-p
Enter a new password to log on:
Enter password :***********
Show logon information: Everything will be OK if the logon is successful

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.