How to forget the root password for MySQL5.7 in Windows 8.1, mysql5.7root

Source: Internet
Author: User

How to forget the root password for MySQL5.7 in Windows 8.1, mysql5.7root

Background]

I recently encountered a very embarrassing problem. I forgot the MySQL password, so I cannot log on to MySQL.

There are many solutions on the Internet and many attempts have been made. They are still abused by various errors in the window. Thanks to the help of the great gods, the MySQL password solution is clear, and I hope the solution process of this blog can help readers.

[Problem solving process]

1. Skip MySQL permission review and enter MySQL

First, find the MySQL my. ini configuration file.

Open the file and add the code skip-grant-tables under mysqld to skip permission review.


An important step: win + R enter services. msc, find the mysql service, and restart the service.

I suspect that this step was not correctly executed during my previous operations. (Also, I have some questions about how I have two MySQL services, one MySQL and one MySQL57. There is no configuration file in the MySQL attribute, while the other is in MySQL57 .)


2. Reset the password in the mysql. user table

First, run cmd to enter the DOS window, MySQL, and press Enter. You can access MySQL without a password. (I couldn't even achieve this step before, so when I successfully enter MySQL, don't mention how happy I am ~~)

Then, let's look at what is in the mysql. user table. Select user, host, authentication_string from mysql. user

(Tips: When I first query the password, I found that this field does not exist. I found out that MySQL5.7 had replaced the password field with authentication_string .)
======================================

Here, let's take a look at the host.

The Host column specifies the IP range that allows users to log on.

For example, user = root Host = 192.168.21.1. This means that the root user can only access the client at 192.168.21.1. % Is a wildcard. If Host = 192.168.1. %, it means that all clients with the IP address prefix "192.168.21." can be connected. If Host = %, all IP addresses have the connection permission. Therefore, when enabling remote connection, most people directly change the Host to %, because this is super convenient.

======================================

An important step: Set the host and password.

Update mysql.user set host="%",authentication_string=password('root') where user='root';

 

3. Refresh permissions. The changed data is updated in the buffer zone. Flush privileges

There is another small question: After the refresh, you can enter mysql directly, there is no way to skip the password review to enter MySQL, however, the configuration file does not comment out the skip-grant-tables statement? Will refreshing ignore the modified configuration file?

Later, I commented out the skip-grant-tables in my. ini ..

4. log on with your password!

First, entermysql -u root -p And then enter the password you just set!

Finally, please make good habits and remember your baby password. :)

[Summary]

I wanted to reinstall MySQL, but it was a bit painful to stick to the problem solved successfully, but the ending was wonderful.

The above section describes how to forget the root password for MySQL5.7 in Windows 8.1. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.