Solution to MySQL root password error number 1045

Solution to MySQL root password error number 1045

Stop MySQL Service

Windows can right-click My Computer--Manage--Services and Applications--Services--find the corresponding service and stop it

Password-free login

Switch to the MySQL installation path: D:\mysql-5.7.24-winx64\bin; if the environment variable has been configured, you do not need to install the directory again

Open a CMD command window and enter the following command in the command line: mysqld -nt --skip-grant-table

For databases older than 8.0, run the following command: mysqld --console --skip-grant-tables --shared-memory

Enter the database

Restart a cmd command window as an administrator, enter: mysql -uroot -p, Enter to enter the database

If you don't want to change the password, but just want to see the original password, you can execute this statement in the command line

select host,user,password from mysql.user; //You can view the user and password

Note: There is no password field in MySQL 5.7 and above. It is encrypted and changed to authentication_string

Change Password

Execute the following statements in the command line

use mysql
update user set password=password("new_password") where user="root"; // Change 'new_password' here to the password you want to set flush privileges;
quit

Note: In MySQL 5.7 and above, replace the statement with

update mysql.user set authentication_string=password('new_password') where user='root'; // Change 'new_password' to the password you want to set

MySQL 5.7 version password setting rules:
It must contain at least one uppercase letter, one lowercase letter, one special symbol, and one number. The password must be at least 8 characters long.

Restart MySQL

Restart MYSQL and enter your password to log in!

mysql -u root -p Enter the password and log in successfully

Summarize

This is the end of this article about how to solve MySQL root password error number 1045. For more information about MySQL root password forgetting, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to reset the root password in mysql8.0.12
  • Summary of how to modify the root password in MySQL 5.7 and MySQL 8.0
  • mysql settings to change the root password, mysql server connection, mysql common commands diagram
  • Detailed explanation of the idea of ​​installing mysql8.0.11 and changing the root password and connecting navicat for mysql
  • Solution to MySql error code 1045 under Windows

<<:  Vue3 navigation bar component encapsulation implementation method

>>:  Detailed explanation of Docker container cross-host multi-network segment communication solution

Recommend

How to generate Hive table creation statement comment script in MySQL metadata

Preface This article mainly introduces the releva...

How to set list style attributes in CSS (just read this article)

List style properties There are 2 types of lists ...

Solution to incomplete text display in el-tree

Table of contents Method 1: The simplest way to s...

Three ways to align div horizontal layout on both sides

This article mainly introduces three methods of i...

Difference between varchar and char types in MySQL

Table of contents aforementioned VARCHAR Type VAR...

Dockerfile implementation code when starting two processes in a docker container

I want to make a docker for cron scheduled tasks ...

Detailed explanation of how to use the canvas operation plugin fabric.js

Fabric.js is a very useful canvas operation plug-...

Solution for creating multiple databases when Docker starts PostgreSQL

1 Introduction In the article "Start Postgre...

Practical notes on installing Jenkins with docker-compose

Create a Directory cd /usr/local/docker/ mkdir je...

Implement 24+ array methods in JavaScript by hand

Table of contents 1. Traversal Class 1. forEach 2...

Tutorial on how to remotely connect to MySQL database under Linux system

Preface I recently encountered this requirement a...

Detailed explanation of viewing and setting SQL Mode in MySQL

Viewing and Setting SQL Mode in MySQL MySQL can r...