> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-codes-1000-to-1099/e1045.md).

# Error 1045: Access denied for user (using password)

| Error Code | SQLSTATE | Error                     | Description                                           |
| ---------- | -------- | ------------------------- | ----------------------------------------------------- |
| 1045       | 28000    | ER\_ACCESS\_DENIED\_ERROR | Access denied for user '%s'@'%s' (using password: %s) |

## Possible Causes and Solutions

The server returns this error when a login fails authentication. The message doesn't say what was wrong: a wrong password, a missing password, and a user name that has no account all give the same error. `using password: YES` means only that the client sent a password, not that the password was correct. `using password: NO` means that the client sent none.

```
$ mariadb -u app -pwrong
ERROR 1045 (28000): Access denied for user 'app'@'localhost' (using password: YES)
$ mariadb -u app
ERROR 1045 (28000): Access denied for user 'app'@'localhost' (using password: NO)
```

To solve the error:

* Check the password. With `using password: NO`, check that the client actually sends one, for example that `mariadb` is called with `-p`, or that the application's connection settings include the password.
* Check that an account exists for the user and the host that the error message names. As a user with access to the `mysql` database, run `SELECT User, Host, plugin FROM mysql.user WHERE User='app';`. When [skip\_name\_resolve](/docs/server/server-management/variables-and-modes/server-system-variables.md#skip_name_resolve) is off, a TCP connection to `127.0.0.1` is also reported as `localhost`.
* Check for an [anonymous account](/docs/server/reference/sql-statements/account-management-sql-statements/create-user.md#anonymous-accounts) that matches the client's host more closely than your account does. The server picks the most specific host first, so `''@'localhost'` wins over `'app'@'%'` for a local connection. The login then fails with this error even with the right password, and without a password it succeeds as the anonymous account. [mariadb-install-db](/docs/server/clients-and-utilities/deployment-tools/mariadb-install-db.md) creates anonymous accounts for `localhost` and the server's host name along with the `test` database, unless it's run with `--skip-test-db`. Remove them with `DROP USER ''@'localhost';`, or with [mariadb-secure-installation](/docs/server/clients-and-utilities/deployment-tools/mariadb-secure-installation.md).

Related errors that are easy to confuse with this one:

* If no account at all matches the client's host, the server returns [error 1130](/docs/server/reference/error-codes/mariadb-error-codes-1100-to-1199/e1130.md) instead, before it checks the user name.
* An account that authenticates with [unix\_socket](/docs/server/reference/plugins/authentication-plugins/authentication-plugin-unix-socket.md) gives [error 1698](/docs/server/reference/error-codes/mariadb-error-codes-1600-to-1699/e1698.md), which has no `using password` part.
* If the login succeeds but the user has no privileges on the database named in the connection, the error is [1044](/docs/server/reference/error-codes/mariadb-error-codes-1000-to-1099/e1044.md).
* A [locked account](/docs/server/security/user-account-management/account-locking.md) still gives this error for a wrong password. Only the right password gets [error 4151](/docs/server/reference/error-codes/mariadb-error-codes-4100-to-4199/e4151.md).

Each failed login is counted in the [Access\_denied\_errors](/docs/server/security/user-account-management/incrementing-of-the-access_denied_errors-status-variable.md) status variable. With the default [log\_warnings](/docs/server/server-management/variables-and-modes/server-system-variables.md#log_warnings) of `2` or higher, it's also written to the [error log](/docs/server/server-management/server-monitoring-logs/error-log.md):

```
2026-10-23 13:34:53 13 [Warning] Access denied for user 'app'@'localhost' (using password: YES)
```

For a step-by-step checklist, see [Troubleshooting Connection Issues](/docs/server/mariadb-quickstart-guides/mariadb-connection-troubleshooting-guide.md).

## See Also

* [When access\_denied\_errors status variable is incremented](/docs/server/security/user-account-management/incrementing-of-the-access_denied_errors-status-variable.md)

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
