MySQL 1045 vs 2002: Access Denied vs Can’t Connect
2002 means the client never reached the MySQL server. 1045 means it reached the server, and the server rejected the login.
1045
MySQL ERROR 1045 (28000): Access denied for user
MySQL rejected the login — wrong password, wrong user/host combination, or the user doesn’t exist.
Causes & fixes →
2002
MySQL ERROR 2002 (HY000): Can't connect to local MySQL server through socket
The client couldn’t reach the MySQL server — it isn’t running, or the client is looking for the socket/port in the wrong place.
Causes & fixes →| 1045 | 2002 | |
|---|---|---|
| Reached the server? | Yes | No |
| Likely problem | Credentials or user@host account | Server down, wrong socket/host/port |
| First check | SELECT user, host FROM mysql.user; | systemctl status mysql |
Rule of thumb
Fix 2002 first (connectivity), then 1045 (credentials).