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

Docker learning method steps to build ActiveMQ message service

Preface ActiveMQ is the most popular and powerful...

The pitfall of MySQL numeric type auto-increment

When designing table structures, numeric types ar...

Linux CentOS 6.5 Uninstall, tar and install MySQL tutorial

Uninstall the system-provided MySQL 1. Check whet...

JavaScript tips to help you improve your coding skills

Table of contents 1. Filter unique values 2. Shor...

MySQL 5.7.18 Green Edition Download and Installation Tutorial

This article records the detailed process of down...

HTML markup language - form

Click here to return to the 123WORDPRESS.COM HTML ...

H tags should be used reasonably in web page production

HTML tags have special tags to handle the title of...

Vue Beginner's Guide: Creating the First Vue-cli Scaffolding Program

1. Vue--The first vue-cli program The development...

Detailed Tutorial on Installing VirtualBox 6.0 on CentOS 8 / RHEL 8

VirtualBox is a free and open source virtualizati...

Why MySQL does not recommend using subqueries and joins

To do a paginated query: 1. For MySQL, it is not ...

Small paging design

Let our users choose whether to move forward or ba...

Web front-end development CSS related team collaboration

The front-end development department is growing, ...

Tips for viewing History records and adding timestamps in Linux

Tips for viewing History records and adding times...