Windows Mysql 5.7 Access denied for user'root'@'localhost' (using password: YES) solution

This article is aimed at the windows version of the solution, and the linux version will be added later when there is time.
I have looked at many methods on the Internet, but have not solved this problem. The solution here is similar to other blog posts, but in more detail.
1. modify the my.ini , my.ini's position is not in the C: \ Program Files \ MySQL \ MySQL Server 5.7 , but in the C: \ ProgramData \ MySQL \ MySQL Server 5.7 under
2. Locate the my.ini [mysqld] , add skip-grant-tables on a new line .
3. Restart the mysql service
4. Enter mysql -u root mysql in the secret command line , and then press Enter without entering the password, as shown in the figure below:
Insert picture description here
5. Enter the following command update user set authentication_string=password('xxxxxx') where in mysql> user='root';, modify the root password, xxxxxx is your own password. The modification is as follows:

Insert picture description here
6. Delete the skip-grant-tables added in my.ini in step 2 , and restart mysql server.
7. Enter mysql> , enter the command mysql -uroot -p , and then enter the password set in step 5, as shown in the figure below Show:
Insert picture description here

Guess you like

Origin blog.csdn.net/hongyinanhai00/article/details/99061662