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)
Access denied
using password: NO (if not output NO)
2.ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
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
Confirm that the mysql service is stopped, otherwise the data file cannot be deleted
2. Delete the data folder in the mysql directory
3. In the bin directory, click the address bar, enter CMD, and press Enter
Enter CMD and press Enter
Enter mysqld --initialize to generate the data folder
4. Under the regenerated data folder, find the .err file
This file contains the password for the regenerated root@localhost
After getting the password, start the mysql service
After confirming the startup, proceed to the next step
After returning to CMD, enter mysql -u root -p, press Enter, and copy the password in the above picture
Finally back to Navicat
After copying the above password into the password field here, click OK
After opening the connection, it will prompt that the password has expired, re-enter the password, and then fill in the personal password.