Error-Linux-MySQL Access denied for user'root'@'localhost' (using password: YES) when logging in

1. Error prompt

Insert picture description here

2. Modify the MySql configuration file my.cnf and add skip-grant-tables

Search for mysqld to
Insert picture description here
add skip-grant-tables, so that mysql can log in without password.
Insert picture description here

3. Restart the service

View all services
Insert picture description here
Restart the mysqld service

Insert picture description here

4. Connect to MySql again and reset the password

Any password can be entered
Insert picture description here
Switch to mysql database
Insert picture description here
Reset password

UPDATE user SET password=PASSWORD("root") WHERE user='root';
  • 1

Insert picture description here

5. Modify the configuration file my.cnf, delete skip-grant-tables, restart, and log in again

Delete skip-grant-tables and
Insert picture description here
restart the service
Insert picture description here
Log in again
Insert picture description here

complete!

Guess you like

Origin blog.csdn.net/zouzh/article/details/113925783