The password is definitely correct, yet you get ERROR 1045 (28000): Access denied for user .... A very common reason: the user was created as 'app_user'@'localhost', but you're connecting over TCP with -h 127.0.0.1.
I reproduced it on MySQL 8.4.13 in a container and ran the check and the fix. Every output below is exactly what the mysql client printed.
Reproduce
As root, create a user that only exists for localhost:
CREATE DATABASE shop; CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'App_Pw_2026'; GRANT ALL ON shop.* TO 'app_user'@'localhost'; Connect with the correct password and an explicit host:
$ mysql -h 127.0.0.1 -u app_user -p'App_Pw_2026' shop ERROR 1045 (28000): Access denied for user 'app_user'@'127.0.0.1' (using password: YES) Look at 'app_user'@'127.0.0.1'. The server sees the client as 127.0.0.1, not localhost. A MySQL account is a user name + host pair, so 'app_user'@'localhost' simply doesn't match this connection.
Check: which hosts does the account have?
SELECT user, host FROM mysql.user WHERE user = 'app_user'; +----------+-----------+ | user | host | +----------+-----------+ | app_user | localhost | +----------+-----------+ 1 row in set (0.00 sec) Only localhost. Put it next to the host in the error message and the mismatch is obvious.
Fix: create an account that matches the client host
CREATE USER 'app_user'@'%' IDENTIFIED BY 'App_Pw_2026'; GRANT ALL ON shop.* TO 'app_user'@'%'; SHOW GRANTS FOR 'app_user'@'%'; +----------------------------------------------------+ | Grants for app_user@% | +----------------------------------------------------+ | GRANT USAGE ON *.* TO `app_user`@`%` | | GRANT ALL PRIVILEGES ON `shop`.* TO `app_user`@`%` | +----------------------------------------------------+ 2 rows in set (0.00 sec) Same command again:
SELECT USER(), CURRENT_USER(); +--------------------+----------------+ | USER() | CURRENT_USER() | +--------------------+----------------+ | app_user@127.0.0.1 | app_user@% | +--------------------+----------------+ 1 row in set (0.00 sec) USER() is where you connected from; CURRENT_USER() is the account you were authenticated as. They're supposed to differ, and comparing them is the fastest way to debug 1045. If % is too broad for you, use the real client address (127.0.0.1, your app server's IP) instead.
Bonus: using password: YES vs NO
Same error number, different tail:
ERROR 1045 (28000): Access denied for user 'app_user'@'127.0.0.1' (using password: NO) NO means no password was sent at all, so check your config file or environment variable first. YES means a wrong password or a host mismatch like the one above.
TL;DR
- Read the host part of
'user'@'host'in the message - Compare it with
SELECT user, host FROM mysql.user WHERE user = '...' - If nothing matches, create the user for the host you actually connect from
I keep the full set of 1045 causes (wrong password, no password sent, host mismatch), each reproduced and fixed on a real MySQL, here:
https://errorfixlab.96ssg.com/en/mysql-1045/
This post was written with the help of generative AI, based on output actually run in a test environment.

