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

Detailed explanation of Nginx reverse proxy example

1. Reverse proxy example 1 1. Achieve the effect ...

Detailed explanation of the usage of setUp and reactive functions in vue3

1. When to execute setUp We all know that vue3 ca...

Detailed explanation of Vue's props configuration

<template> <div class="demo"&g...

Analysis of different MySQL table sorting rules error

The following error is reported when MySQL joins ...

Optimizing the slow query of MySQL aggregate statistics data

Written in front When we operate the database in ...

Four categories of CSS selectors: basic, combination, attribute, pseudo-class

What is a selector? The role of the selector is t...

How to prevent hyperlink redirection using JavaScript (multiple ways of writing)

Through JavaScript, we can prevent hyperlinks fro...

A brief discussion on the use of Web Storage API

Table of contents 1. Browser local storage techno...

MySQL 5.7 installation and configuration method graphic tutorial

This tutorial shares the installation and configu...

Vue ElementUI implements asynchronous loading tree

This article example shares the specific code of ...

Linux five-step build kernel tree

Table of contents 0. The kernel tree that comes w...

Css3 realizes seamless scrolling and anti-shake

question The seamless scrolling of pictures and t...