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

Linux uses NetworkManager to randomly generate your MAC address

Nowadays, whether you are on the sofa at home or ...

Axios project with 77.9K GitHub repository: What are the things worth learning?

Table of contents Preface 1. Introduction to Axio...

Vue custom components use event modifiers to step on the pit record

Preface Today, when I was using a self-written co...

Docker image compression and optimization operations

The reason why Docker is so popular nowadays is m...

Difference between var and let in JavaScript

Table of contents 1. Scopes are expressed in diff...

MySQL replication advantages and principles explained in detail

Replication is to transfer the DDL and DML operat...

Six border transition effects implemented by CSS3

Six effectsImplementation Code html <h1>CSS...

Detailed explanation of the mysql database LIKE operator in python

The LIKE operator is used in the WHERE clause to ...

Call and execute host docker operations in docker container

First of all, this post is dedicated to Docker no...

CSS to achieve particle dynamic button effect

Original link https://github.com/XboxYan/no… A bu...

Tomcat Nginx Redis session sharing process diagram

1. Preparation Middleware: Tomcat, Redis, Nginx J...

25 Tools to Improve Website Usability and Conversion Rates

For a website, usability refers to whether users c...

CentOS 8 Installation Guide for Zabbix 4.4

Zabbix server environment platform ZABBIX version...

Problems and solutions of using jsx syntax in React-vscode

Problem Description After installing the plugin E...