MySQL / Editorial solution guide
Access denied: account, host, plugin, or privilege?
Classify a failed MySQL 8.4 connection before changing credentials or grants.
Read-only knowledge base ยท No public comments
Recognize the symptoms
ERROR 1045 (28000): Access denied can occur during login. Its user and host context matters; using password: YES only means a password was supplied, not that it was correct.
A successful login followed by ERROR 1044 (42000) or ERROR 1142 (42000) is a different stage: schema or statement authorization. Plugin errors can also appear after an upgrade.
Understand the likely causes
- MySQL accounts match a user and host combination. The application may be reaching another endpoint, using a socket instead of TCP, or matching a different server account than expected.
- A stale secret, incompatible client plugin support, disabled authentication plugin, locked account, or missing active role requires a different correction. One error excerpt does not identify which cause applies.
Record the failing stage
Capture the exact error code, client version, intended endpoint, transport, requested username, and whether any SQL statement succeeded. Redact passwords and connection strings. An unreachable endpoint or TLS certificate failure is not evidence that table grants are wrong. If login fails, the following SQL cannot be run through that failed connection; use existing authorized administrative diagnostics instead.
Check the account that actually matched
After an authorized login succeeds, compare the client identity with the privilege-checking account and active roles. A role may be granted but inactive. These are inspection queries only; results depend on the connection and should not be copied into public issue reports.
SELECT VERSION(),USER(),CURRENT_USER(),CURRENT_ROLE();
SHOW GRANTS FOR CURRENT_USER;
USER and CURRENT_USER need not describe the same account matching context. Identify the intended narrow permission before requesting a change; successful authentication already rules out several login-only hypotheses.
Have an administrator inspect matching rows
An authorized administrator can inspect only the relevant account rows, without selecting password hashes. Check exact host scope, account locking, and plugin compatibility with the server and connector. A localhost socket and remote TCP connection can match differently; do not add a wildcard host merely to make the error disappear.
SELECT User,Host,plugin,account_locked
FROM mysql.user WHERE User='lab_reporter' ORDER BY Host;
The synthetic account name is lab_reporter. This query needs access to account metadata and is for an existing authorized administrator. It intentionally excludes authentication_string and makes no account or privilege changes.
Apply the correction supported by evidence
For stale credentials, use the established rotation process and refresh connection pools. For endpoint or host mismatch, correct routing or the narrowly intended account definition. MySQL 8.4 disables mysql_native_password by default and normally uses caching_sha2_password; prefer a compatible updated connector and a reviewed account migration rather than enabling legacy authentication indiscriminately. For authorization failures, request only the missing relation privilege or role activation.
Keep transport verification intact
A TCP client using caching_sha2_password must satisfy the documented secure-transport or RSA exchange requirements. Validate server certificates through the connector configuration; do not disable verification to diagnose a password. SHOW SESSION STATUS LIKE 'Ssl_cipher' can help inspect a successful TLS session, while local socket transport follows a different security context.
Verify the fix
Reconnect through the same application transport and account, then run one approved synthetic read such as SELECT id FROM mysql_course_lab.orders ORDER BY id LIMIT 1. Confirm the matched account, required role, and expected permission; a successful administrator session does not verify the application account.
Keep it from recurring
- Inventory server and connector versions, test credential rotation, separate migration and runtime accounts, and retain host-scoped least-privilege grants. MySQL and MariaDB plugin and role behavior must be reviewed separately.