How does one forget the root password for mysql in windows?

Source: Internet
Author: User
A friend told me early this morning that his mysql has forgotten the root password and asked me to help you. Because I have never been in touch with mysql, I found the information on the Internet and I have already practiced it myself! Mysql 5.1 or lower is the information found on the Internet: 1. First, check whether the mysql service is started. If it has been started, stop it. You can run it in the Start Menu.

This morning, a friend told me that his mysql had forgotten the root password and asked me to help me with it. Because I had never been in touch with mysql, I found the information on the Internet and it was already done by myself! Mysql 5.1 or lower is the information found on the Internet: 1. First, check whether the mysql service is started. If it has been started, stop it. You can run it in the Start Menu.

This morning, a friend told me that his mysql had forgotten the root password and asked me to help you. I found the information online because I have never been in touch with mysql.

I have already put it into practice! The mysql version is 5.1

The following information is obtained from the Internet:

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 FilesMySQLMySQL Server 5.1my.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

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.