1045-Access denied for user root@localhost(using password:YES) solution

1045-Access denied for user root@localhost(using password:YES) solution

Hello everyone, many friends have encountered this problem when installing MySQL. This blog is here to solve this problem. Study hard and read carefully. You can basically solve it by following my step by step instructions.

first step

Run cmd as administrator , enter the bin file of mysql, and run the command: sc delete MySQL , as shown below:

Insert image description here

After deleting the mysql service, you will no longer see it in the service. If you can still see it, you can manually right-click and select Stop , and the service will disappear, as shown below:

Insert image description here

Step 2

Change the basedir and datadir in the my.ini configuration file to your correct path, which must be the path where you installed MySQL, as shown below:

Insert image description here

third step

Regenerate the data file, delete the data file under mysql, and back up important data tables first. Regenerate the data file in cmd and enter in data:
mysqld --initialize-insecure --user=mysql.
After the command is executed, a new data file will be generated in the mysql folder, as shown below:

Insert image description here

Insert image description here

the fourth step

Reinstall the mysql service, bind the my.ini configuration file, and execute the command in cmd: mysqld --install "MySQL" --defaults-file="G:\MySQL\mysql-8.0.22-winx64\my.ini "
"MySQL" is the service name, which can be modified by yourself; "...\my.ini" is the location of the newly created configuration file, as shown below:

Insert image description here
Insert image description here

the fifth step

Start mysql: Enter the command in cmd: net start MySQL . If the startup is successful, as shown below:

Insert image description here

Step 6

Directly enter Navicat to connect to MySQL, as shown below:

Insert image description here
Insert image description here

Insert image description here

To change the password here, I reset the password in Navicat. I think Navicat is more convenient. It is too complicated to modify it using the command line. I recommend that you download Navicat when using MySQL:

Conclusion

Please read this article and take a look at the installation and configuration of MySQL8.0.22 , so that problems will be less likely to occur. The solution will be here. Welcome to give us your advice, communicate with each other, and learn together.

Guess you like

Origin blog.csdn.net/qq_43715354/article/details/110853263