MySQL 1045 "Access Denied for User": Three Real Causes

Symptom

Cannot connect; ERROR 1045 (28000).

Root cause

Wrong password, wrong host pattern, or auth plugin mismatch.

Fix, in order

1. The host part of the grant mattersSELECT user, host FROM mysql.user WHERE user='app'; # app@localhost vs app@%
2. Old client vs caching_sha2_passwordALTER USER 'app'@'%' IDENTIFIED WITH mysql_native_password BY '...';
3. Apply the grant you think you appliedGRANT ALL ON appdb.* TO 'app'@'%'; FLUSH PRIVILEGES;

Prevent it coming back

One user per app; grants in migrations, not muscle memory.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

Managed cloud hosting

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.

Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog