gogoWebsite

Access denied for user 'root'@'localhost' (using password: YES) can't be opened during MySQL login solution

Updated to 6 months ago

θ―·ζ·»εŠ ε›Ύη‰‡ζθΏ°

  • πŸ’Œ Affiliated Columns:[Program Error Solution (Recommended)]

  • πŸ˜€ Writer:I'm a dog in the dead of night.

  • πŸš€ Personal Profile: a CV engineer who is trying to learn technology, focusing on basic and practical sharing , welcome to consult!

  • πŸ’– Welcome: this is CSDN, the place where I summarize my knowledge, please triple link if you like, and private message if you have any questions 😘 😘 😘 😘 😘

Your likes, followers, favorites, and comments are the biggest incentive and support for me!!!! 🀩 🀩 🀩 🀩

θ―·ζ·»εŠ ε›Ύη‰‡ζθΏ°

Article Catalog

  • preamble
  • I configuration: system 64 bit win10, MySQL8.0.16
  • II. Analysis of causes
  • III. Solutions
    • 1. Program I
    • 2. Option II
  • IV. Summary


preamble

  In the process of learning the database, there are always some strange problems, such as the first two days with a good day, the day a use of the crash, really was crashed in a face of confusion. Can only go to Baidu to search for solutions, Baidu a few days, found that many methods are not very applicable, some can only be used half, so sex himself on the summary of those who are useful, the former planted a tree after the cooler Well, once in a while when the former is also good πŸ‰ πŸ‰ πŸ‰ πŸ‰.
  I just hope to reduce the time for people to search, comparatively time is money πŸ‘ πŸ‘ πŸ‘. If there's anything in the article that needs to be improved please don't hesitate to tell me. πŸ‘ πŸ‘ πŸ‘ πŸ‘.By the way, the other day I found a giant AI learning website that is easy to understand and funny, I can't help but share it with you.Click to go to website。


I configuration: system 64 bit win10, MySQL8.0.16

   incorrect :ERROR 1045 (28000): Access denied for user β€˜root’@β€˜localhost’ (using password: YES)

εœ¨θΏ™ι‡Œζ’ε…₯图片描述

II. Analysis of causes

  From the meaning of the English passage above, it can be analyzed like this:

  • First: Access denied;
  • Second: using password: NO/YES. here the using password is whether the password is entered or not, if it is entered, it means YES, if not, it outputs NO.

εœ¨θΏ™ι‡Œζ’ε…₯图片描述
εœ¨θΏ™ι‡Œζ’ε…₯图片描述

  According to a lot of information on the Internet, there are the following possible reasons for the appearance of Access denied:

  • MySQL's server is down.
  • The user's port number or IP causes access to be denied
  • MySQL configuration file errors (etc. files)
  • Wrong password for root user

εœ¨θΏ™ι‡Œζ’ε…₯图片描述

III. Solutions

  • Step 1 : Restart the MySQL server:net start mysql
    εœ¨θΏ™ι‡Œζ’ε…₯图片描述

  • Step 2 : If the user's port number is the same as theIP(3306/3307οΌ‰ Inconsistency, open The file is edited. Replace all edits with:port=X

  • Step 3 : If the file is misconfigured, you can refer to the following article, which has made a change to the The document is explained and annotated.Link to article.

  • Step 4 Here are two solutions if your password is wrong.

1. Program I

   The first one: hit the path where you installed MySQL beforedata file. Then use Notepad to open the file that starts with.err for files with a suffix.

εœ¨θΏ™ι‡Œζ’ε…₯图片描述
  here areerr The file will keep the passwords that were saved when the database was created, but of course sometimes the passwords are overwritten due to cache refresh issues.

εœ¨θΏ™ι‡Œζ’ε…₯图片描述

  Note: Just log in again after you know the password. If you can't find the password in the err file or still have a login error, try the second method.

2. Option II

  The second one: with--init-file The parameter loads and runs the command file to change the password when the service starts. Once the command is executed, the password is cleared or reset after the service starts, and you can log in with an empty password or a specified password after starting the service.

  • Step 1 : Shut down the server first:
    εœ¨θΏ™ι‡Œζ’ε…₯图片描述
  • Step 2 : Create atxt text file namedmysqlc, then write a command in text to change the password. I created this in the directory where MySQL is installed.
    εœ¨θΏ™ι‡Œζ’ε…₯图片描述
    εœ¨θΏ™ι‡Œζ’ε…₯图片描述
  • Step 3 : Starts the server from the command line, specifying that the password change command file described above is executed at startup.

mysqld --init-file=Q:\MySQL\mysql-8.0.16-winx64\ --console

εœ¨θΏ™ι‡Œζ’ε…₯图片描述

  Note: Make sure that the Mysql service is shut down before executing Step 3.

  • Step 4 : Then restart the server:
    εœ¨θΏ™ι‡Œζ’ε…₯图片描述
  • Step 5 : Then just enter it with the password you just changed.
    εœ¨θΏ™ι‡Œζ’ε…₯图片描述
      The above I used to solve the problem, I hope to help you, thank you for watching.

θ―·ζ·»εŠ ε›Ύη‰‡ζθΏ°


IV. Summary

  Thanks for watching and if it helped, please like and favorite the article so more people can see it. 🌹 🌹 🌹 🌹 🌹 🌹

εœ¨θΏ™ι‡Œζ’ε…₯图片描述

  You are also welcome, to follow me. πŸ‘ πŸ‘ πŸ‘

  The original is not easy, but also hope that you big brother support, your likes, favorites and comments are really important to me!!!! πŸ’• πŸ’• πŸ’• πŸ’• Finally, this article still has a lot of shortcomings, welcome you to seriously read the article partners feel free to private communication, criticism and correction! See you in the next issue. πŸŽ‰

More columns to subscribe to.

  • πŸ˜€ LeetCode problem solving (continuously updating)
  • 🌼 [Hongmeng System]
  • πŸ‘‘ [Python Scripting Notes]
  • 🚝 [Java Web Project Build Process]
  • πŸ’› [micro letter small program development tutorial]
  • ⚽ [JavaScript Random Notes
  • 🀩 [Big Data Study Notes (Huawei Cloud)]
  • πŸ¦„ [Program Error Solution (Recommended)]
  • πŸš€ [Software Installation Tutorial]



Subscribe for more and you'll see more quality content!