How to solve the error "ERROR 1045 (28000)" when logging in to MySQL

How to solve the error "ERROR 1045 (28000)" when logging in to MySQL

Today, I logged into the server and prepared to modify some things in the database. But after entering the password, I cannot enter the database and an error message is displayed, as shown below

Even after confirming that the password is correct, I still cannot enter the database. I found a solution on the Internet and wrote it down for reference.

Solution:

The overall idea is: (under Linux system) shut down the MySQL service, configure MySQL to log in without a password, then reset the password, refresh the database, remove the previous configuration, and restart MySQL.

1. Shut down the MySQL service, command: service mysqld stop. Find your MySQL configuration file. The location of each person's installation may be different. For example, my configuration file is as follows

2. In the directory where the configuration file is located, use the vim command to edit it, command: vim my.cnf

Enter vim editing mode again, press insert, and add skip_grant_tables at the specified location in the figure below, as shown in the figure below

3. Save and exit the configuration file, command: ① shift + semicolon ② enter wq ③ press Enter. This configures password-less login. Start the database, command: service mysqld start. Enter the database, type in the command line: mysql -u root -p, and then press Enter to enter the database O(∩_∩)O

4. After entering the database, set a new password for the database. If you still want to use the previous password, you can set it back to the previous password. This is also possible.

Command (press Enter after each command):

① use mysql;

② update user set password=password("new password") where user="root"

③flush privileges;

④ quit;

Note: The second command is suitable for MySQL 5.6 and earlier versions. There is no password field after MySql5.7. You should execute update user set authentication_string = password('newpassword') where user='root'; to change the password.

5. After the database password is changed, comment out the modified part of the original database configuration file by adding a # sign before the statement.

6. Restart the database service, command: service mysqld restart . At this time, you can log in to the database with the password you just set~\(≧▽≦)/~

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Solution to mysql ERROR 1045 (28000) problem
  • How to solve the mysql ERROR 1045 (28000)-- Access denied for user problem
  • ERROR 1045 (28000): Access denied for user ''''root''''@''''localhost''' (using password: YES) Practical solution
  • Solve the problem of ERROR 1045 (28000): Access denied for user ''root''@''localhost'' when logging in after installing MySQL 5.7.17 on Ubuntu 16.04
  • MySQL ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO) Causes and solutions
  • MySQL login error prompt: Solution to ERROR 1045 (28000)
  • MYSQL ERROR 1045 (28000): Access denied for user (using password: YES) solution
  • Solve mysql: ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO/YES)

<<:  Weird and interesting Docker commands you may not know

>>:  Example of using store in vue3 to record scroll position

Recommend

nuxt.js multiple environment variable configuration

Table of contents 1. Introduction 2. Scenario 3. ...

Steps to install Pyenv under Deepin

Preface In the past, I always switched Python ver...

VMware, nmap, burpsuite installation tutorial

Table of contents VMware BurpSuite 1. Virtual mac...

How to change password and set password complexity policy in Ubuntu

1. Change password 1. Modify the password of ordi...

Implementation of Vue 3.x project based on Vite2.x

Creating a Vue 3.x Project npm init @vitejs/app m...

Install MySQL 5.7 on Ubuntu 18.04

This article is compiled with reference to the My...

Implementing WeChat tap animation effect based on CSS3 animation attribute

Seeing the recent popular WeChat tap function, I ...

TABLE tags (TAGS) detailed introduction

Basic syntax of the table <table>...</tab...

How to modify the default network segment of Docker0 bridge in Docker

1. Background When the Docker service is started,...

Node uses async_hooks module for request tracking

The async_hooks module is an experimental API off...

Problems and solutions of using TweenMax animation library in angular

I have nothing to do recently, so I tinker with C...

Installation and configuration tutorial of MySQL 8.0.16 under Win10

1. Unzip MySQL 8.0.16 The dada folder and my.ini ...

Some tips on deep optimization to improve website access speed

<br />The website access speed can directly ...