Mysql 1045 Access denied for user 'root'@'localhost' (using password: YES/NO) Personal solution to share

foreword

Mysql 1045 Access denied for user 'root'@'localhost' (using password: YES/NO)
I have read many articles but have not solved it. Here is my personal solution to share

1. Personal configuration: system win10, MySQL: 8.0.30 database tool: Navicat

Second, the root user password error

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

insert image description here

Access denied

using password: NO (if not output NO)

2.ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

insert image description here

Access denied

using password: YES (if entered, it means YES)

3. Solutions

1. Stop mysql service

CTRL+ALT+DELETE Open Task Manager, switch to "Services", select right click to stop

insert image description here

insert image description here

Confirm that the mysql service is stopped, otherwise the data file cannot be deleted

insert image description here

2. Delete the data folder in the mysql directory

insert image description here

3. In the bin directory, click the address bar, enter CMD, and press Enter

insert image description here

Enter CMD and press Enter

insert image description here

insert image description here

Enter mysqld --initialize to generate the data folder

insert image description here

4. Under the regenerated data folder, find the .err file

insert image description here

This file contains the password for the regenerated root@localhost

insert image description here

After getting the password, start the mysql service

insert image description here

insert image description here

After confirming the startup, proceed to the next step

insert image description here

After returning to CMD, enter mysql -u root -p, press Enter, and copy the password in the above picture

insert image description here

Finally back to Navicat

insert image description here

After copying the above password into the password field here, click OK

insert image description here

After opening the connection, it will prompt that the password has expired, re-enter the password, and then fill in the personal password.

insert image description here
insert image description here

After modification

insert image description here

Finally, thanks to the two articles

li.siyuan reference link
I am Yelan's dog reference link

Guess you like

Origin blog.csdn.net/weixin_51519327/article/details/129050905