This is a searchable reference for MySQL error codes — both the server errors that the database raises and the client errors that the connector library raises. Each entry carries the numeric code, the symbolic name, the portable SQLSTATE and a short, practical note on what to do, so you can decode a failed query or a dropped connection fast.
How it works
MySQL splits its error numbers into two ranges. Server errors start at 1000 and are defined in mysqld_error.h — for example 1062 ER_DUP_ENTRY or 1213 ER_LOCK_DEADLOCK. Client errors start at 2000 and are defined in errmsg.h — for example 2003 CR_CONN_HOST_ERROR or 2013 CR_SERVER_LOST. Most errors also expose a 5-character SQLSTATE for portable handling (HY000 is the generic class). Search by number, symbol, SQLSTATE or keyword to find the matching row and its fix.
Reading the error
Three signals tell you where the problem lives. A number ≥ 2000 means the issue is connectivity or the client, not your SQL. A SQLSTATE of 23000 means a constraint violation (duplicate, NULL, or foreign key). A SQLSTATE of 40001 (deadlock) or message mentioning “lock wait timeout” means contention — retry the whole transaction rather than just the statement.
Example
A frequent pairing on a busy table:
ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
InnoDB detected a deadlock and rolled back one of the transactions. The correct response is to retry the entire transaction from the beginning, because the rolled-back transaction lost all its work. Adding indexes and keeping transactions short reduces how often it happens. Everything here runs in your browser; nothing is uploaded.