Solution to forgetting mysql database password

Solution to forgetting mysql database password

You may have set a MySQL password just now, but forget it when you go out to eat or pick up a package... Should we panic at this time? ? ? ?

Don't worry, brothers, I will solve your troubles of forgetting passwords~

The following is a summary of the video of Teacher Lin Haifeng

You can think of MySQL's function of obtaining username and password verification as a decorator in Python, which is decorated on the function that the client requests access.

If we remove this decorator, the MySQL server will not verify the username and password! ! ! !

# 1. First shut down the current MySQL server. # Start by command (let MySQL skip the username and password verification function)
# mysqld --skip-grant-tables
# Start on the server and open cmd as an administrator 

# 2. Connect directly without a password # mysql -uroot -p and press Enter 

# 3. Modify the password of the current user. # The user information is stored in user.frm in the mysql folder. # update mysql.user set password=password(new password) where user='root' and host='localhost';
'''
The field that actually stores the password of the user table must be stored in ciphertext. Only the user himself knows what the plaintext is, and no one else knows it. This is more secure. Password comparison can only compare ciphertext. MySQL calls the password() method to encrypt the password.''' 

# 4. Immediately flush the modified data to the hard disk # flush privilege; 

# 5. Close the current server and then start it in the normal way of verifying the authorization table 

Click Start and then click Restart.

Reopen a normal cmd to start mysql and enter the new password

This is the end of this article about how to solve the problem of forgetting the MySQL database password. For more information about forgetting the MySQL password, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Problem of retrieving root password in MYSQL 5.7 under Linux (tested and available)
  • How to reset MySQL root password
  • Quick solution for forgetting MySQL8 password

<<:  Json advantages and disadvantages and usage introduction

>>:  Introduction to root directory expansion under Linux system

Recommend

Analysis of basic usage of ul and li

Navigation, small amount of data table, centered &...

mysql command line script execution example

This article uses an example to illustrate the ex...

MySQL 8.0.20 installation and configuration detailed tutorial

This article shares with you a detailed tutorial ...

How to generate mysql primary key id (self-increment, unique and irregular)

Table of contents 1. Use the uuid function to gen...

Some pitfalls of JavaScript deep copy

Preface When I went to an interview at a company ...

How to deploy MySQL master and slave in Docker

Download image Selecting a MySQL Image docker sea...

Detailed explanation of Bootstrap grid vertical and horizontal alignment

Table of contents 1. Bootstrap Grid Layout 2. Ver...

How to understand the difference between ref toRef and toRefs in Vue3

Table of contents 1. Basics 1.ref 2. toRef 3. toR...

Vue implements verification code countdown button

This article example shares the specific code of ...

Detailed explanation of query examples within subqueries in MySql

Where is my hometown when I look northwest? How m...

Vue uses Baidu Maps to realize city positioning

This article shares the specific code of Vue usin...

How to encapsulate axios request with vue

In fact, it is very simple to encapsulate axios i...

How to set focus on HTML elements

Copy code The code is as follows: <body <fo...