【MySQL】解决mysql:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

background

I haven't used sql for a long time, and when I open it in cmd, I report an error:

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

go through

When I first logged in, it reported ERROR 2003.

insert image description here
Open "Service", there is no MySQL at this time

Solution:

mysqld --install
net start mysql

insert image description here
Then type:

mysql -u root -p

Just report an error:

insert image description here

I suspect that the previous reinstallation of sql caused the problem.

Solution

Edit my.ini configuration: add skip-grant-tables under [mysqld] and save it.

Specific process:

my.ini is on the directory of sql. If you forget the location of sql, you canSearch for "service", find MySQL, right-click properties,You will know where it is installed.

insert image description here
Find the corresponding location, right-click my.ini, and edit in Notepad:

Add it under [mysqld] and save it.

skip-grant-tables

insert image description here
Then you can log in.

insert image description here

reference

Solve mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES) - Winton-H - Blog Garden (cnblogs.com)

The location of the mysql configuration file my.ini under windows_windowsmysql configuration file_sam_zhang1984's blog-CSDN blog

Guess you like

Origin blog.csdn.net/karshey/article/details/130904544