Solution for forgetting the root password of MySQL5.7 under Windows 8.1

Solution for forgetting the root password of MySQL5.7 under Windows 8.1

【background】

I encountered a very embarrassing thing while studying recently. I forgot my MySQL password, so I couldn’t log in to MySQL.

There are many solutions on the Internet. I have tried many of them, but I am still tortured by various errors in the window. Thanks to the help of the great god, the solution to MySQL forgotten password has become clear. I hope the solution process in this blog can help readers.

【Problem solving process】

1. Skip MySQL permission review and enter MySQL

First, find the my.ini configuration file for MySQL.

 

Then, open the file and add a line of code skip-grant-tables under mysqld to skip the permission review.

                                

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

I suspect that I did not perform this step correctly when I did it before. (Also, I have some doubts here. Why do I have two MySQL services, one MySQL and one MySQL57? There is no configuration file in the MySQL properties, but there is one for MySQL57.)


2. Reset password in mysql.user table

First, enter the DOS window with cmd, enter MySQL, and press Enter. You can successfully enter MySQL without a password. (I couldn’t even do this before, so when I successfully entered MySQL, I was so happy~~)

Then, let's take a look at what's in the mysql.user table. select user,host,authentication_string from mysql.user

(Tips: When I first searched for password, I found that this field did not exist. Later, I checked online and found that MySQL 5.7 replaced the password field with authentication_string <Chinese meaning authentication string>.)
=================================

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

The Host column specifies the IP range from which the user is allowed to log in.

For example, user=root Host=192.168.21.1. What this means is that the root user can only access it through the client 192.168.21.1. % is a wildcard. If Host=192.168.1.%, it means that any client with an IP address prefix of "192.168.21." can connect. If Host=%, it means all IPs have connection permission. That’s why when opening a remote connection, most people simply change Host to % because it’s super convenient.

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

A very important step: we set the host and password.

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

 

3. Refresh permissions to update the data that has been changed and is in the buffer. flush privileges

I have another question: after refreshing, if you directly enter mysql, there is no way to skip the password verification and enter MySQL, but the configuration file clearly has not commented out the skip-grant-tables sentence? Will refreshing ignore the configuration file that was just modified?

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

4. Log in using your password!

First, enter mysql -u root -p , then enter the password you just set, and you can log in successfully!

Finally, please develop a good habit and remember your baby password. :)

【summary】

I wanted to reinstall MySQL, but I persisted until the problem was successfully solved. The process was a bit painful, but the ending was good.

The above is the solution for forgetting the root password of MySQL5.7 under Windows 8.1 introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Detailed tutorial on how to modify the root password after forgetting it in MySQL 5.7
  • How to change the root password of Mysql5.7.10 on MAC
  • What to do if you forget the root password of Mysql5.7 (simple and effective method)
  • Solution to forgetting the root password of MySQL5.7 on Mac
  • MySQL 5.7 installation process and method to reset the root password (shell script)
  • Detailed method for forgetting the root password or resetting the password in Mysql 5.7
  • Problem of retrieving root password in MYSQL 5.7 under Linux (tested and available)

<<:  Summary of Linux nc command

>>:  About Vue virtual dom problem

Recommend

Detailed explanation of Linux index node inode

1. Introduction to inode To understand inode, we ...

Example code of the spread operator and its application in JavaScript

The spread operator allows an expression to be ex...

Detailed explanation of eight methods to achieve CSS page bottom fixed

When we are writing a page, we often encounter a ...

Design Theory: Ten Tips for Content Presentation

<br /> Focusing on the three aspects of text...

Analysis of the difference between Mysql InnoDB and MyISAM

MySQL supports many types of tables (i.e. storage...

HTML table markup tutorial (9): cell spacing attribute CELLSPACING

A certain distance can be set between cells in a ...

How to implement Vue binding class and binding inline style

Table of contents Binding Class Binding inline st...

Use ab tool to perform API stress test on the server

Table of contents 1 A brief introduction to syste...

MYSQL updatexml() function error injection analysis

First, understand the updatexml() function UPDATE...

A super detailed Vue-Router step-by-step tutorial

Table of contents 1. router-view 2. router-link 3...

A small collection of html Meta tags

<Head>……</head> indicates the file he...

Example of implementing colored progress bar animation using CSS3

Brief Tutorial This is a CSS3 color progress bar ...