A brief analysis of the best way to deal with forgotten MySQL 8 passwords

A brief analysis of the best way to deal with forgotten MySQL 8 passwords

Preface

Readers who are familiar with MySQL may find that MySQL is updated very quickly. In terms of installation, MySQL provides two classic installation methods: decompression and one-click. Although there are two installation methods, I prefer the decompression installation, which is not only fast but also clean. In terms of operating system, MySQL also supports multiple types of operating systems, such as Linux, Windows, etc. The following are several operating systems with major changes in MySQL.

Through research and analysis, it is not difficult to find that: as MySQL iterates from low versions to high versions, increasingly rigorous security is one of its major features. For example, before version 6, when you forget your password, it is very convenient to reset it. You only need to perform the following two steps:

Step 1: Skip the permissions table

mysqld --skip-grant-tables

Step 2: Leave the password blank

UPDATE user SET authentication_string='' WHERE user='root';

However, this solution is not applicable to MySQL 8.

This article will solve the problem of resetting the password if you forget the MySQL 8 password. It mainly includes three aspects

Content 1: Briefly describe the decompression installation of MySQL 8

Content 2: Forgot your password and reset it Solution 1

Content 3: Forgot your password and reset it Solution 2

One installation

1. Download the installation package from the official website (the official website provides two installation methods: visual installation and decompression). This example is based on the decompression method. Official website download address: https://dev.mysql.com/downloads/mysql/

2. Unzip the installation package and put it in the C:\MySQL directory

3. Configure environment variables

MySQL_HOME="C:\MySQL\mysql-8.0.15-winx64"

PATH="%MySQL_HOME%\bin"

4. Open DOS as an administrator

(1) Start the service

mysqld --install

(2) Initialize and generate an initialization password (MySQL 7+ does not have a data directory, so the data directory is installed initially)

mysqld --initialize --user=mysql --console

(3) Start the service

net start mysql

(4) Log in

Account root, password is the temporary password A*v)(Ivw7xjQ generated by the initial session, which needs to be changed after logging in

(5) Change the root password

Format: alter user 'user name'@'login host' identified by 'password (custom)';

(6) Log in with new password

(7) Extended commands

Remove service: mysql --remove

Stop the mysql service: mysql stop mysql

Exit mysql:exit

2. Solve the problem of forgetting password

(I) Plan 1

1. Enter DOS as an administrator

2. Stop the mysql service

net stop mysql

3. Start without password

mysqld --console --skip-grant-tables --shared-memory

4. Open another DOS window and log in without a password

5. Clear password

Note: authentication_string uses plugin encryption, so set it to empty and do not set it to other values.

6. Start the service

Close the two open DOS windows, then reopen a DOS window as an administrator and start the service

net start mysql

7. Password-less login

mysql -u root

8. Reset your password

After modification, you can log in with the new password.

9. Log in with new password

(II) Solution 2: Using the --init-file parameter

1. Stop the service

net stop mysql

2. Create the ResetPWD.txt file in the c:\MySQL directory. The content of the file is

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

3. Execute the ResetPWD.txt file

mysqld --init-file=c:\mysql\ResetPWD.txt --console, after execution, close the DOS window

4. Start mysql

net start mysql

5. Log in with your new password

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • How to reset password after forgetting password in MySQL8 (MySQL old method doesn't work)
  • The perfect solution for forgetting the password in mysql8.0.19
  • Solution for forgetting the root password of MySQL5.7 under Windows 8.1
  • Pitfalls encountered when installing MySQL 8.0.18 compressed package and resetting forgotten passwords
  • mysql8.0 forgotten password modification and net command service name invalid problem
  • Quick solution for forgetting MySQL8 password

<<:  Solve the cross-domain problem of Vue+SpringBoot+Shiro

>>:  How to implement Docker Registry to build a private image warehouse

Recommend

Super detailed basic JavaScript syntax rules

Table of contents 01 JavaScript (abbreviated as: ...

Vue.js implements tab switching and color change operation explanation

When implementing this function, the method I bor...

How to store images in MySQL

1 Introduction When designing a database, it is i...

How to implement digital paging effect code and steps in CSS

A considerable number of websites use digital pagi...

MySQL complete collapse query regular matching detailed explanation

Overview In the previous chapter, we learned abou...

How to achieve 3D dynamic text effect with three.js

Preface Hello everyone, this is the CSS wizard - ...

Example of how to enable Slow query in MySQL

Preface Slow query log is a very important functi...

How to optimize MySQL performance through MySQL slow query

As the number of visits increases, the pressure o...

How to implement animation transition effect on the front end

Table of contents Introduction Traditional transi...

Detailed explanation of how to use Teleport, a built-in component of Vue3

Table of contents 1. Teleport usage 2. Complete t...

Detailed analysis of the chmod command to modify file permissions under Linux

Use the Linux chmod command to control who can ac...

SMS verification code login function based on antd pro (process analysis)

Table of contents summary Overall process front e...

js realizes packaging multiple pictures into zip

Table of contents 1. Import files 2. HTML page 3....

A brief discussion on the design and optimization of MySQL tree structure tables

Preface In many management and office systems, tr...