ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES) 或(password: NO)

When logging in to Mysql and entering the password, an error like this occurred.

Error message 1:

or

Error message 2:

Solution one (simple)

This error occurs because many people forget their password. You can use this command to view the mysql default password:

grep 'temporary password' /var/log/mysqld.log

example:

Use this command to find out my mysql password is: s:*8jexp7OX_

When logging in to mysql using the mysql -u root -p command, you can copy it to the password column.

Solution 2

1. Edit the directory

vim /var/log/mysqld.log

 2. After entering, enter / first , then password -> press the Enter key (enter) , as shown in the figure below:

3. Then it will automatically locate the line with the mysql password for you, copy the password after root@localhost  and log in to mysql.

Exit command: first enter :, then enter exit ->  press the Enter key (enter) , as shown in the figure below:

 

 over. . .

Guess you like

Origin blog.csdn.net/weixin_62332711/article/details/126672287