VPS Tutorials
MySQL 1045 Access Denied: Fix Password, User@Host and Docker Login Errors (2026)
Diagnose MySQL 1045 with explicit endpoints, account matching and authentication plugins. Fix Docker password rotation without deleting database volumes.

MySQL error 1045 (28000): Access denied for user 'app'@'10.0.0.8' (using password: YES) calls for three checks: the server you reached, the account you supplied, and the client address MySQL sees. YES means a password was supplied; it does not establish that it was correct.
This guide targets MySQL 8.4 on a Linux VPS, including Docker Compose deployments. MariaDB has different authentication plugins and system-table details. The commands are an operational guide, not a report of changes made to your server.
| Message | Investigate |
|---|---|
1045 ... using password: YES | Credentials, account matching and authentication requirements |
1045 ... using password: NO | Usually a missing password; also inspect plugin and client settings |
1044 ... to database | Database authorization rather than the initial login |
2002, 2003, timeout or connection refused | Socket, service, listener and networking |
1040 Too many connections | Connection capacity and application pools |
1524 Plugin ... is not loaded | Server authentication plugin |
A 1045 reply means a MySQL server answered the authentication request. It could still be the wrong instance. For transport failures, use the MySQL and MariaDB connectivity guide. The official troubleshooting reference explains the error fields.
Use the same endpoint and username as the application:
mysql --protocol=TCP --connect-timeout=5 \
-h 127.0.0.1 -P 3306 -u app -p
Replace the example host and port. Keep the TLS and certificate-verification options required by your deployment. Enter the password at the prompt rather than adding it to the command line or sharing an unredacted connection URL.
On Linux, a default localhost connection commonly uses a Unix socket. A successful socket login does not prove that the application's TCP login uses the same server or matching account. Inside an application container, 127.0.0.1 is that container. Applications on the same Compose network normally use the database service name, such as mysql:3306.
If a comparable manual login works, inspect the application's live configuration: endpoint, username, actual Secret source and credential reload behavior. Reserved characters such as @, : and / require appropriate encoding when credentials are embedded in a connection URL. Follow your driver's URL rules; separate password fields do not necessarily require URL encoding.
Use an existing administrator session or your established management login. For a Compose database service named mysql:
docker compose exec mysql mysql -u root -p
This still requires valid database credentials. sudo mysql works only where the installation's authentication configuration permits it.
With the necessary administrative privileges, inspect the instance and account rows:
SELECT VERSION(), @@hostname, @@port;
SELECT User, Host, plugin, account_locked, password_expired
FROM mysql.user
WHERE User IN ('app', '')
ORDER BY Host, User;
app@localhost, [email protected] and app@% are separate account rows and can have different passwords. The host part describes the connecting client as seen by MySQL. Docker, NAT or a proxy can change that address.
MySQL selects a matching row according to specificity; it does not merge passwords or grants from every matching row. A specific host can take precedence over %. Anonymous local accounts can also affect selection. Check the official connection-verification rules before changing a broad account that may not be used.
In a successful new application-account session, run:
SELECT USER(), CURRENT_USER(), @@hostname, @@port;
SHOW GRANTS;
USER() describes the client's identity; CURRENT_USER() identifies the account used for privileges. A rejected session cannot run these queries, so combine the error message, administrator inspection and a successful comparison session.
The following examples assume an existing database named appdb and a verified source address of 10.0.0.8. Replace both values. Choose the appropriate branch; do not execute both as a blind repair script.
If the account does not exist:
CREATE USER 'app'@'10.0.0.8'
IDENTIFIED WITH caching_sha2_password BY 'REPLACE_WITH_UNIQUE_SECRET';
GRANT SELECT, INSERT, UPDATE, DELETE
ON appdb.* TO 'app'@'10.0.0.8';
If that account exists and you have confirmed a password rotation is needed, with a driver that supports caching_sha2_password:
ALTER USER 'app'@'10.0.0.8'
IDENTIFIED WITH caching_sha2_password BY 'REPLACE_WITH_UNIQUE_SECRET';
Use a unique strong password in a controlled management session and protect SQL history and recordings. This explicit plugin change is for an application account confirmed to use MySQL's internal password authentication. Do not overwrite an administrator's socket, LDAP or other authentication arrangement.
Coordinate the change with every application using this account. Give migrations their required privileges separately rather than granting the runtime account global access. CREATE USER, ALTER USER and GRANT normally take effect without FLUSH PRIVILEGES; do not edit mysql.user directly. See the ALTER USER reference.
The official mysql image uses variables such as MYSQL_ROOT_PASSWORD, MYSQL_USER and MYSQL_PASSWORD during initialization. An existing database directory is left intact when the container starts. Changing an environment variable and recreating the container therefore does not rewrite existing account passwords. See the official image documentation.
A complete rotation updates the correct account inside MySQL, updates the application's real credential source, and reloads the application so it creates fresh connections.
For an application service named app, after checking the resolved deployment, image and expected interruption:
docker compose up -d --no-deps --force-recreate app
This can interrupt the application. Replace the service name. A simple docker compose restart app does not apply changed Compose environment variables to the existing container.
Do not use docker compose down -v as a production password reset: it can remove database volumes. If storage has already changed, use the Compose data recovery guide.
If the password contains $, distinguish .env quoting from Compose YAML escaping. Single-quoted .env values are literal; a literal dollar sign in Compose YAML uses $$ where interpolation applies. docker compose config can reveal resolved secrets, so inspect locally and redact before sharing. Check the interpolation documentation.
mysql_native_password is disabled by default in MySQL 8.4 and was removed in MySQL 9.0. Check the server version, account plugin, driver version and full error before migrating the specific account. Upgrade the client where needed; do not switch all users to an obsolete plugin. The official plugin reference documents these version boundaries.
TLS or RSA exchange errors need their own driver-specific treatment. Disabling certificate verification is not a credential repair. If every administrator login is unavailable, use the installed version's documented password recovery procedure after checking backups and arranging maintenance. Do not delete the data directory or leave the server running with grant checks disabled.
Create a fresh connection, confirm CURRENT_USER() and the server identity, then run the smallest read/write check your application requires. Review new logs for 1045 errors. Existing pooled sessions are not evidence that new credentials work. Keep the original administrator session until new application connections are stable.
Next steps: