The command line mysqld –skip-grant-tables cannot be successfully started in mysql8, and the parameter cannot be started in the ini file. The MySQL password is stored in the user table. Changing the password actually means changing the record in the table. The idea of resetting is to find a way to enter the system without a password, and then use database commands to modify the password record in the user table. After checking, the method recommended by MySQL5 system on the Internet is to start the MySQL service with the --skip-grant-tables parameter, which indicates that the authorization table is not loaded at startup, so after successful startup, the root user can log in with an empty password
After logging in, you can use
These commands set the password or leave it blank. However, the command line such as mysqld –skip-grant-tables cannot be successfully started in mysql8, and the parameter cannot be started in the ini file. Two ideas for resetting the MySQL8 system password There are two ways of thinking. You can use the --init-file parameter to load and run the command file for changing the password when the service starts. Once the command is executed, the password will be cleared or reset after the service starts. After starting the service, you can log in with an empty password or a specified password. Or continue to study the reason why the service cannot be started under the –skip-grant-tables command line parameter, solve the problem, then start the service and log in with an empty password, manually enter the command to clear or reset the password record field in the mysql.user table. The former is recommended. The specific operation process is as follows: Method 1: Use the --init-file parameter to solve This parameter specifies that a SQL command file is executed when the service is started. Therefore, you only need to write the command to reset the password in the file and use this parameter to specify that the command is executed at startup. After the startup is complete, you can reset the system password. The first step is to shut down the system service
The second step is to create a text file containing a password modification command
Step 3: Start the server in command line mode and specify the password modification command file to be executed at startup
Specific operation screenshots Method 2: Find a way to use the --skip-grant-tables parameter Same as method 1, turn off the system service first In actual testing, under the mysql8 system, using mysqld –console –skip-grant-tables –shared-memory can start the service without a password After the service is started, log in to the system with an empty password
Then execute the sql command to set the root user password to empty
Specific operation screenshots Due to some features of MySQL 8, the old reset method is not very effective. It is recommended to use the –init-file parameter to solve the problem. It has been tested to be safe and reliable. Losing your database management password is a real headache. If you cannot retrieve it successfully, you will be in a lot of trouble. Most of the solutions found online are out of date. It is recommended that you save this article and pay attention to it in case you need it. You may also be interested in:
|
<<: Tips for viewing text in Linux (super practical!)
>>: Detailed explanation of Vue advanced construction properties
1. <div></div> and <span></s...
Table of contents 1. The difference between multi...
Download and install. First check whether there i...
Preface We all know that MySQL query uses the sel...
Table of contents principle Network environment p...
Q1: What indexes does the database have? What are...
This article example shares the specific code for...
Table of contents 1. Open the file Parameter Intr...
Sprites: In the past, each image resource was an ...
React multiple ways to get the value of the input...
What is Let’s first look at the concept of Docker...
Install Remote-SSH and configure it First open yo...
A new window opens. Advantages: When the user cli...
doctype is one of them: <!DOCTYPE HTML PUBLIC &...
1. Install Fcitx input framework Related dependen...