Fix MySQL "Access Denied for User" (Error 1045)
Access denied for userERROR 1045 (28000)using password: YESError 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.
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.
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;
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.
MySQL is a trademark of Oracle Corporation. MariaDB is a trademark of MariaDB Foundation. ESAGAMES is an independent hosting provider, not affiliated with or endorsed by Oracle.
Databases handled for you
Our managed hosting sets up MySQL/MariaDB with the right users and grants, so game panels and apps just work.
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.
Related articles
Fix SSH "Connection refused" / "Connection timed out"
SSH "connection refused" vs "timed out" — what each means and the exact steps to fix them.
Read fix Linux & VPSFix "Permission denied" on Linux (chmod & chown Explained)
"Permission denied" on a script or file? Understand chmod/chown and fix it the right way.
Read fix Linux & VPSHow to Check CPU, RAM & Disk Usage on a Linux Server
The essential commands to check CPU, RAM and disk on Linux — and find what's eating them.
Read fix