Fix MySQL ERROR 1045 (28000): Access denied for user root@localhost (using password: YES)

How to fix ERROR 1045 28000 - Access denied for user username@localhost using password- YES
Code2care@Mac % mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: YES)

Let us break down the error codes first

    1045: This is a MySQL-specific error code for authentication failure.

    28000: This is a general SQLSTATE error code that indicates what was the cause of the authorization issue.

Cause of this issue:

    The cause of this issue is self-explanatory by the error code 28000 message. You have provided incorrect login credentials to connect to the MySQL database.


  1. Username/Passwords are case sensitive. Make sure they are in the right case.
  2. Make sure you have provided the correct username/password.
  3. If the credentials are correct, make sure you are trying to connect to the right database (e.g. uat/staging/production)
  4. Make sure the user/password has not expired.

If you are using the default installation, in most of cases, root user does not have a password. So when you try to connect to MySQL via the console, when prompted for a password, just press enter without inputting anything via the keyboard.

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap