VillageSQL is a drop-in replacement for MySQL with extensions.
All examples in this guide work on VillageSQL. Install Now →
ERROR 2002: Can’t Connect Through Socket
(2) is errno 2, “no such file”.
- Check the server is up:
pgrep mysqldor your service manager. mysql -h localhostuses a Unix socket. If the server listens on a different socket path, pass it:mysql -S /path/to/mysql.sock.- To force TCP instead of the socket, use
-h 127.0.0.1, not-h localhost.
ERROR 1045: Access Denied
- The user the server thinks you are.
- The host you connected from. MySQL accounts are
user@hostpairs:'app'@'localhost'and'app'@'%'are different accounts with different passwords and grants. using password: YES/NO— whether a password was sent at all.NOoften means the client found no password in the environment or config file it read.
SELECT user, host FROM mysql.user; as an admin) and resetting its password with ALTER USER. See User management.
ERROR 1055: ONLY_FULL_GROUP_BY
customer_id but many total values, and the query never says which one it wants. Old MySQL versions picked one arbitrarily; since 5.7 the default ONLY_FULL_GROUP_BY mode makes this an error, and it is protecting you from a query that was wrong all along. Three real fixes:
ONLY_FULL_GROUP_BY in sql_mode also works and is the wrong answer: it turns the error back into silently arbitrary results. See GROUP BY and HAVING.
ERROR 1064: Syntax Error
ERROR 1062: Duplicate Entry
- The row should never exist twice: fix the generator of the duplicate key.
- The insert should update the existing row instead: use
INSERT ... ON DUPLICATE KEY UPDATE. See Upsert. - The insert should be skipped silently:
INSERT IGNORE, used sparingly, since it also silences other errors.
Reading Any MySQL Error
The patternERROR <number> (<SQLSTATE>): <message> carries three signals. The number is MySQL-specific and the best search key. The SQLSTATE class is portable: 28000 is authentication, 42000 is a query problem, 23000 is a constraint violation, HY000 is the general bucket. Client-side errors (2xxx, like 2002) never reached the server; server-side errors (1xxx) mean the connection works.
See also
- User management — the account model behind access-denied errors
- GROUP BY and HAVING — writing aggregate queries that pass ONLY_FULL_GROUP_BY
- Upsert — turning duplicate-key errors into updates

