MySQL Error Troubleshooting
Find MySQL error guides by code or message, covering connections, access, data changes, tables, storage limits, SQL syntax, transactions, and foreign keys.
When a MySQL statement fails, note the numeric error code, SQLSTATE, full message, and server version. The same schema problem can have a generic message in one release and a more specific error in another. The MySQL server error reference lists the codes and messages for MySQL 8.4.
For connection-pool sizing and the difference between account limits, storage exhaustion, and lock memory, see MySQL Capacity Planning.
Connection and authentication
- Error 2002: the local socket connection failed
- Error 2003: the client cannot connect to the MySQL server
- Error 2015: the Windows named-pipe connection failed
- Error 2005: the client cannot resolve the MySQL server hostname
- Error 2006: the server has gone away after the connection was made
- Error 2013: the connection was lost during a query
- Error 1042: the server cannot get the hostname for the client address
- Error 1043: the server rejected a bad connection handshake
- Error 2026: SSL connection error
- Error 1045: account authentication was denied
- Error 1524: the
mysql_native_passwordplugin is not loaded - Error 2059: the client authentication plugin cannot be loaded
- Error 1040: too many connections
- Error 1203: one MySQL account has too many connections
- Error 1226: a MySQL account resource limit was reached
- Error 1129: host is blocked after connection errors
- Error 1130: the client host is not allowed to connect
Data changes and column values
- Error 1048: a column cannot be
NULL - Error 1264: a numeric value is outside the column range
- Error 1175: safe update mode blocked the statement
- Error 1062: duplicate entry for a primary or unique key
- Error 1136: column and value counts differ in an
INSERT - Error 1136 at row 2 in a multi-row
VALUESstatement - Error 1364: a required field has no default value
- Error 1406: data is too long for a column
Database and table errors
- Error 1007: a database already exists
- Error 1044: access denied to a database
- Error 1142: command denied for a table
- Error 1143: command denied for a column
- Error 1046: no database selected
- Error 1049: an unknown database was named
- Error 1050: a table already exists
- Error 1051: an unknown table is named in
DROP TABLE - Error 1060: a column name is duplicated
- Error 1061: an index name is duplicated
- Error 1146: a referenced table does not exist
- Error 1114: the table or storage area is full
Queries and SQL syntax
- Error 1054: unknown column and alias scope
- Error 1054: unknown column in
UNION ORDER BY - Error 1055: a selected column is not allowed by
ONLY_FULL_GROUP_BY - Error 1064: SQL syntax error
- Error 1093: an
UPDATEsubquery reads the target table - Error 1222:
UNIONqueries return different column counts - Error 1250: a table name is not allowed in the global
ORDER BYof aUNION - Error 3942: an empty row in a
VALUEStable constructor
Transactions and locks
- Error 1206: InnoDB lock table full
- Error 1213: deadlock found when trying to get a lock
- Error 1205: lock wait timeout exceeded
Foreign key constraints
These errors occur at different stages. Error 1215 is a generic foreign-key definition failure; Error 1822 names a missing index in the referenced parent table; Error 6125 identifies a missing unique parent key; Error 3780 identifies incompatible child and parent column definitions. Error 1452 instead means a child row has no matching parent row.
For a quick browser-side check of common column, engine, and parent-key conditions, open the local MySQL foreign-key checker. It does not connect to a database or send the values you enter; confirm any finding against the live table definitions.
-
Duplicate foreign-key constraint names: check schema-wide names and version-specific diagnostics
-
Error 1451: a parent row cannot be deleted or updated while children reference it