MySQL Error 1045: Access Denied for User (28000)
Fix MySQL Error 1045 by checking the password, user@host account, server and protocol, and account authentication or lock status.
On this page
MySQL Error 1045 (28000, ER_ACCESS_DENIED_ERROR) means the server rejected the connection during authentication. A common message is:
ERROR 1045 (28000): Access denied for user 'app_user'@'localhost' (using password: YES)
using password: YES means the client sent a password; it does not mean the password was correct. The MySQL 8.4 error reference lists the code and message.
Confirm which server and account the client is reaching
Check the host, port, user name, and connection method in the application or MySQL client. For an interactive command-line login, specify the password option without putting the password in the command:
mysql --host=db.example.com --port=3306 --user=app_user --password
The client prompts for the password. MySQL recommends prompting rather than exposing the password on the command line in its password security guidance.
MySQL accounts include both a user name and a host. An account named 'app_user'@'localhost' is distinct from 'app_user'@'%'; a grant or password change for one account does not necessarily apply to the other. On Unix-like systems, classic MySQL clients usually connect to localhost through a socket, while 127.0.0.1 uses TCP. Changing the host can therefore change which account MySQL matches. See the MySQL connection transport documentation.
Check credentials and account settings
If the host, port, and user are correct, verify the password through the client’s prompt or protected secret configuration. Avoid printing secrets into shell history, logs, or support messages.
If the password may be wrong or the account may not exist, ask a database administrator to check the exact user@host account. MySQL connection verification checks the user, client host, credentials, and authentication plugin; an administrator can inspect the account with SHOW CREATE USER and reset it with ALTER USER if appropriate. Update the application’s stored secret at the same time as any password reset.
If the server explicitly reports that the account is locked, follow the MySQL account-locking tutorial instead of treating the message as a password mismatch.
Distinguish Error 1045 from Error 1044
- Error 1045 (
28000): the server rejected the connection before the client could run SQL statements. - Error 1044 (
42000): the account connected, but lacks a privilege required to access a database. See MySQL Error 1044 troubleshooting.
Granting database privileges does not fix an incorrect password or a user/host mismatch. For user creation syntax, see the MySQL CREATE USER tutorial. Browse more fixes in MySQL error troubleshooting.