Skip to content
Linux & VPS

Fix MySQL "Access Denied for User" (Error 1045)

Access denied for userERROR 1045 (28000)using password: YES
8 min read Updated 12 June 2026 ESAGAMES Team

Error 1045 means MySQL rejected the login. The fix depends on which part failed — the password, the host the user is allowed from, or missing privileges. Here's how to find and fix it, plus the auth-plugin and case-sensitivity gotchas.

Read the error carefully

The message tells you a lot: Access denied for user 'app'@'localhost' (using password: YES) means the user, the host (localhost) and that a password was sent. using password: NO means no password was provided at all.

The exact wording narrows it down fast — match yours here, then go to the fix:

The error shows…Likely causeFix
(using password: YES)Wrong password for that userReset the password (Cause 1)
(using password: NO)App sent no password at allSet the password in the app config
user@'localhost' but you connect remotelyUser not allowed from that hostGrant the user for the right host (Cause 2)
Login works but queries are deniedMissing privileges on the databaseGRANT the needed privileges (Cause 3)
Worked before an upgradeAuth-plugin mismatchAlign the user's auth plugin (below)

Cause 1: wrong password

The most common cause. Reset it (as root) and update your app config to match:

ALTER USER 'app'@'localhost' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;

Cause 2: wrong host

A user defined as app@localhost can't connect from another IP. If your app connects over the network, create/grant the user for that host:

CREATE USER 'app'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON mydb.* TO 'app'@'%';
FLUSH PRIVILEGES;
localhost vs 127.0.0.1

MySQL treats them differently: localhost uses a Unix socket, 127.0.0.1 uses TCP. A user granted on one may be denied on the other. Match how your app actually connects.

Cause 3: missing privileges

The user exists and the password is right, but it has no rights on the database. Grant them as shown above, scoped to the specific database.

Verify the user

SELECT user, host FROM mysql.user WHERE user = 'app';
SHOW GRANTS FOR 'app'@'localhost';
1045 is always user + password + host. Confirm the password, confirm which host the user is allowed from, and confirm the grants.

Cause 4: wrong authentication plugin

MySQL 8 defaults new users to caching_sha2_password, which some older clients/drivers can't speak, producing what looks like a plain access-denied. If your app can't support the new plugin, switch the user to the legacy mysql_native_password plugin with an ALTER USER ... IDENTIFIED WITH mysql_native_password BY 'password' statement, then FLUSH PRIVILEGES.

Cause 5: leftover skip-grant-tables or case sensitivity

If the server was ever started with --skip-grant-tables for a manual fix and not restarted cleanly afterward, grants can end up inconsistent. Also remember usernames are case-sensitive on most systems — App and app are different users.

How to prevent 1045 errors

  • Store credentials in environment variables/config, not hardcoded — makes rotating a leaked password fast.
  • Grant the narrowest host you actually need (a specific IP) rather than % where possible.
  • After any migration or restore, re-check that users and grants moved with the data — a dump can miss the mysql.user table.

Related errors

If the database service itself won't start, see fixing MySQL/MariaDB won't start. WordPress sites showing a database error from the same root cause are covered in fixing "Error establishing a database connection". phpMyAdmin login issues are covered in fixing phpMyAdmin access denied.

Databases handled for you

Our managed hosting sets up MySQL/MariaDB with the right users and grants, so game panels and apps just work.

See hosting
FAQ

Frequently asked questions

What does MySQL error 1045 mean?

"Access denied for user" — the login was rejected. It's caused by a wrong password, the user not being allowed from that host, or missing privileges on the database.

Why does it say "using password: YES" but still deny me?

A password was sent but it's wrong, or the user isn't permitted from the host you're connecting from. Reset the password and check the user's host (localhost vs 127.0.0.1 vs %).

What's the difference between localhost and 127.0.0.1 in MySQL?

localhost connects via a Unix socket; 127.0.0.1 connects via TCP. MySQL grants are host-specific, so a user allowed on one might be denied on the other. Grant the host your app actually uses.

Why does error 1045 happen right after a WordPress or app migration?

A database dump/restore doesn't always bring the mysql.user table and grants with it. Recreate the user and grants on the new server, matching the exact host your app connects from.

Can an authentication plugin cause "access denied" even with the right password?

Yes — MySQL 8's default caching_sha2_password plugin isn't supported by every old client library. Switch the user to mysql_native_password if your app or driver can't use the newer plugin.

Are MySQL usernames case-sensitive?

Yes, on virtually all setups — "App" and "app" are treated as different users. Double-check the exact case used when the user was created versus what your app sends.

Knowledge base

Related articles

Skip the troubleshooting

Managed, protected hosting in Frankfurt — we handle the Linux, the network and the DDoS so you don't have to.

Payments Secure checkout with cards, banking apps and digital wallets.

Choose the payment flow that fits your stack and region without leaving the platform.

Pay by Zen Visa Mastercard Paysafecard PaysafeCash Skrill Trustly Bancontact UnionPay iDeal WebMoney