【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 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:
|
<<: Summary of Linux nc command
>>: About Vue virtual dom problem
Table of contents First install wget View Help Ma...
Nginx is now one of the most popular load balance...
Preface As we all know, HTML5 belongs to the Worl...
Table of contents Business Logic Data table struc...
@Font-face basic introduction: @font-face is a CSS...
In addition to setting regulations for various ta...
This article uses examples to explain the Nginx c...
Table of contents 1. Overview of MySQL Logical Ar...
Preface This article introduces a simple BAT scri...
From today on, I will regularly organize some smal...
HTML-centric front-end development is almost what ...
Table of contents Preface zx library $`command` c...
Vue routing this.route.push jump page does not re...
The fastest way to experience the latest version ...
Sometimes in a project, due to some irreversible ...