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

A detailed introduction to wget command in Linux

Table of contents First install wget View Help Ma...

Understanding Nginx Current Limitation in One Article (Simple Implementation)

Nginx is now one of the most popular load balance...

HTML 5.1 learning: 14 new features and application examples

Preface As we all know, HTML5 belongs to the Worl...

Example of implementing grouping and deduplication in MySQL table join query

Table of contents Business Logic Data table struc...

Basic usage of @Font-face and how to make it compatible with all browsers

@Font-face basic introduction: @font-face is a CSS...

How to pass W3C validation?

In addition to setting regulations for various ta...

Detailed explanation of Nginx current limiting configuration

This article uses examples to explain the Nginx c...

Analyze how a SQL query statement is executed in MySQL

Table of contents 1. Overview of MySQL Logical Ar...

Simple Mysql backup BAT script sharing under Windows

Preface This article introduces a simple BAT scri...

Some understanding of absolute and relative positioning of page elements

From today on, I will regularly organize some smal...

HTML is the central foundation for the development of WEB standards

HTML-centric front-end development is almost what ...

The ultimate solution for writing bash scripts with nodejs

Table of contents Preface zx library $`command` c...

Solution for Vue routing this.route.push jump page not refreshing

Vue routing this.route.push jump page does not re...

Detailed steps for quick installation of openshift

The fastest way to experience the latest version ...

How to use union all in MySQL to get the union sort

Sometimes in a project, due to some irreversible ...