How to recover deleted MySQL 8.0.17 root account and password under Windows

How to recover deleted MySQL 8.0.17 root account and password under Windows

I finished learning SQL by myself not long ago, and downloaded MySQL 8.0.17. After installing and configuring it, I explored it and wondered if I could delete the root account by logging in with the root account. Then I wanted to slap myself...

How to quickly restore root:

1. Close the MySQL service: press win+R, type services.msc, find the MySQL service, and click stop;

2. Delete the data folder and its files: Enter the mysql folder, find the data folder and delete it;

3. Initialize mysql: Enter services.msc again and run the mysql service; enter the mysql\bin file path in the cmd window and run mysqld --initialize --console. The result is similar to the following:

2019-08-07T02:08:11.300849Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2019-08-07T02:08:11.724874Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-08-07T02:08:12.024891Z 0 [Warning] InnoDB: Creating foreign key constraint
system tables.
2019-08-07T02:08:12.056893Z 0 [Warning] No existing UUID has been found, so we a
ssume that this is the first time that this server has been started. Generating
a new UUID: 35611a71-b8b8-11e9-8e24-28d24409926b.
2019-08-07T02:08:12.064893Z 0 [Warning] Gtid table is not ready to be used. Tabl
e 'mysql.gtid_executed' cannot be opened.
2019-08-07T02:08:12.076894Z 1 [Note] A temporary password is generated for root@
localhost: QTpg4Y!sh:dk

Note that the bold statement contains the temporarily generated root account password;

4. Run mysql in cmd: type mysql -u root -p+root password; Note: p is the abbreviation of password. According to the above example, you should type: mysql -u root -pQTpg4Y!sh:dk -p and password must be connected together to be effective, without space in between;

5. Modify the temporary root password: Run the SQL statement: alter alter user root@localhost identified by ' root密碼' ; Note: The password must be contained in English single quotes '', otherwise it will be invalid and an error will be reported. The semicolon at the end must also be written.

6. Check whether the query is successful: Run the SQL statement: select user from mysql.user; 成功顯示root賬戶;

Note: Although this method is quick and effective, it will delete all database files, that is, the databases in the data folder. I have tried adding skip-grant-tables to bypass login authentication, but it is not effective for version 8.0.17.

Summarize

The above is what I introduced to you on how to recover the deleted Mysql8.0.17 Root account and password under Windows. I hope it will be helpful to you!

You may also be interested in:
  • Implementation of MySQL5.7 mysqldump backup and recovery
  • Two methods of restoring MySQL data
  • Steps for restoring a single MySQL table
  • MySQL database backup and recovery implementation code
  • MySQL uses mysqldump+binlog to completely restore the deleted database principle analysis
  • Analysis of MySQL data backup and recovery implementation methods
  • Shell script to implement mysql scheduled backup, deletion and recovery functions
  • Sharing of the fast recovery solution for Mysql large SQL files
  • MySQL Binlog Data Recovery: Detailed Explanation of Accidentally Deleting a Database
  • How to restore a database and a table from a MySQL full database backup
  • MySQL quick recovery solution based on time point

<<:  JavaScript to achieve calendar effect

>>:  Detailed steps for installing, configuring and uninstalling QT5 in Ubuntu 14.04

Recommend

How to use docker to deploy Django technology stack project

With the popularity and maturity of Docker, it ha...

Web Design Teaching or Learning Program

Section Course content Hours 1 Web Design Overvie...

Summary of MySql storage engine and index related knowledge

Storage Engine What is a database storage engine?...

A detailed introduction to Linux memory management and addressing

Table of contents 1. Concept Memory management mo...

Detailed explanation of the underlying encapsulation of Java connection to MySQL

This article shares the Java connection MySQL und...

MySQL 8.0.21 installation and configuration method graphic tutorial

Record the installation and configuration method ...

Issues and precautions about setting maxPostSize for Tomcat

1. Why set maxPostSize? The tomcat container has ...

Detailed explanation of nmcli usage in CentOS8

Common nmcli commands based on RHEL8/CentOS8 # Vi...

Summary of horizontal scrolling website design

Horizontal scrolling isn’t appropriate in all situ...

Summary of three ways to implement ranking in MySQL without using order by

Assuming business: View the salary information of...

Suggestions on creating business HTML emails

Through permission-based email marketing, not onl...

W3C Tutorial (5): W3C XML Activities

XML is designed to describe, store, transmit and ...

Three solutions for sub-functions accessing external variables in JavaScript

Preface When we write web pages, we will definite...