A simple and effective solution to forget the initial password when installing MySQL

A simple and effective solution to forget the initial password when installing MySQL

When you install MySQL, you will be given an initial password, and this initial password is particularly disgusting with a bunch of uppercase and lowercase special characters. Remember, it is impossible. If you have no installation experience before, you will most likely not pay attention to this when you install it yourself for the first time.

The MySQL version used in this tutorial is version 8.0.19. This method should be available for version 8. I’m not sure about other versions, so you can try it. If you are proficient in the whole process, it can be done in two minutes.

First, the tutorial.

Just do it, the previous findings are all nonsense

1. First, make sure that the folder (data) in the datadir in the my.ini file is not created manually

[client]
#Set the default character set of MySQL client default-character-set=utf8

[mysqld]
#Set port to 3306
port=3306
#Set the installation directory of mysql basedir=F:\\MYSQL\\mysql-8.0.19-winx64\\mysql-8.0.19-winx64
#Set the storage location of the mysql database. You don't need to set datadir=F:\\MYSQL\\mysql-8.0.19-winx64\\mysql-8.0.19-winx64\\data
#Maximum number of connections allowed max_connections=20
#The character set used by the server defaults to the 8-bit latin character set character-set-server=utf8
#The default storage engine used when creating a new table default-storage-engine=INNODB

2. Delete the data folder

3. Open cmd in administrator mode, enter the MySQL installation directory, and enter:

sc delete mysql

4. Reinitialize the database (write down the password generated in this step, or you may forget it)

mysqld --initialize --console

5. Reinstall MySQL

mysqld install

Then try again and see if it can be started.

it's over? There is no next step to teach you how to change your password. There are a bunch of codes on the Internet.

6. Add the following line under mysqld in the my.ini file (skip password verification when logging in??? Oops, then all my steps above were... wasted):

skip-grant-tables

7. After saving and exiting, retype

mysql -uroot -p

8. At this point, you have entered the MySQL database. The next few steps are also set up successfully by me learning from others. You can use it yourself. Type in order:

flush privileges;
alter user 'root'@'localhost'IDENTIFIED BY 'the new password you want to set';

This will make the new password effective.

But one thing to remember is to remove the line of code (skip-grant-tables) added to the ini file .

Following the above 8 steps compiled by 123WORDPRESS.COM, you can completely solve the problem of forgetting the initial password. Thank you for learning.

You may also be interested in:
  • What to do if you forget the initial password when installing MySQL on Mac
  • How to install and modify the initial password of mysql5.7.18 under Centos7.3
  • How to modify the initial password of a user in mysql5.7
  • What to do if you forget the initial password of MySQL on MAC
  • What to do if you forget the initial password of MySQL on MAC

<<:  Example of how to quickly build a Redis cluster with Docker

>>:  Detailed discussion of the differences between loops in JavaScript

Recommend

Example code for implementing page floating box based on JS

When the scroll bar is pulled down, the floating ...

Summary of MySQL character sets

Table of contents Character Set Comparison Rules ...

Detailed explanation of how to restore database data through MySQL binary log

Website administrators often accidentally delete ...

How to set static IP in centOS7 NET mode

Preface NAT forwarding: Simply put, NAT is the us...

Complete steps to achieve high availability with nginx combined with keepalived

Preface In order to meet the high availability of...

Introduction to Docker Architecture

Docker includes three basic concepts: Image: A Do...

Detailed explanation of four types of MySQL connections and multi-table queries

Table of contents MySQL inner join, left join, ri...

CSS performance optimization - detailed explanation of will-change usage

will-change tells the browser what changes will h...

Solution to the long delay of MySQL database master-slave replication

Preface The delay of MySQL master-slave replicati...

Basic usage examples of Vue named slots

Preface Named slots are bound to elements using t...

Detailed explanation of two points to note in vue3: setup

Table of contents In vue2 In vue3 Notes on setup ...

Detailed explanation of mysql user variables and set statement examples

Table of contents 1 Introduction to user variable...

Javascript implements simple navigation bar

This article shares the specific code of Javascri...

Vue el-date-picker dynamic limit time range case detailed explanation

There are two situations 1. Start time and end ti...