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

Detailed explanation of the command mode in Javascript practice

Table of contents definition structure Examples C...

Detailed process analysis of docker deployment of snail cinema system

Environmental Statement Host OS: Cetnos7.9 Minimu...

MySQL Workbench download and use tutorial detailed explanation

1. Download MySQL Workbench Workbench is a graphi...

Detailed explanation of Nginx configuration required for front-end

Nginx (engine x) is a lightweight, high-performan...

Detailed explanation of component development of Vue drop-down menu

This article example shares the specific code for...

Disable autocomplete in html so it doesn't show history

The input box always displays the input history wh...

MySQL index pushdown details

Table of contents 1. Leftmost prefix principle 2....

Linux remote control windows system program (three methods)

Sometimes we need to remotely run programs on the...

Detailed summary of web form submission methods

Let's first look at several ways to submit a ...

ffmpeg Chinese parameter description and usage examples

1. When ffmpeg pushes video files, the encoding f...

How to view MySQL links and kill abnormal links

Preface: During database operation and maintenanc...

Java programming to write a JavaScript super practical table plug-in

Table of contents Effects Documentation first ste...

The use of v-model in vue3 components and in-depth explanation

Table of contents Use two-way binding data in v-m...