MySQL error codes
The MySQL server and client errors people hit most, each with the message text, symbol and SQLSTATE from the MySQL error reference, what the error means and how to fix it.
Reading a MySQL error
MySQL reports errors as ERROR 1062 (23000): Duplicate entry '7' for key 'users.PRIMARY'. The number is the MySQL error code, the five characters in brackets are the SQLSTATE, and the rest is the message with its placeholders filled in.
Codes from 1000 up to 1999 and from 3000 up are raised by the server. Codes from 2000 to 2999 are raised by the client library, usually because the connection could not be made or was lost, so the server may never have seen the statement.
Run SHOW WARNINGS; after a statement to see warnings and notes, which use the same numbers. Many data errors, such as 1265 or 1366, are warnings in non-strict SQL modes and errors in strict mode.
All MySQL errors in this reference
79 codes, 79 with a full write-up (linked). Codes and messages are from the MySQL 8.4 Error Message Reference.
Connection and client
| Code | Meaning |
|---|---|
2002
|
Can't connect through socket
CR_CONNECTION_ERROR
Can't connect to local MySQL server through socket '%s' (%d)
|
2003
|
Can't connect to MySQL server on host
CR_CONN_HOST_ERROR
Can't connect to MySQL server on '%s:%u' (%d)
|
2005
|
Unknown MySQL server host
CR_UNKNOWN_HOST
Unknown MySQL server host '%s' (%d)
|
2006
|
MySQL server has gone away
CR_SERVER_GONE_ERROR
MySQL server has gone away
|
2013
|
Lost connection to MySQL server during query
CR_SERVER_LOST
Lost connection to MySQL server during query
|
2055
|
Lost connection to MySQL server at stage
CR_SERVER_LOST_EXTENDED
Lost connection to MySQL server at '%s', system error: %d
|
2026
|
SSL connection error
CR_SSL_CONNECTION_ERROR
SSL connection error: %s
|
2059
|
Authentication plugin cannot be loaded
CR_AUTH_PLUGIN_CANNOT_LOAD
Authentication plugin '%s' cannot be loaded: %s
|
2061
|
Authentication plugin reported error
CR_AUTH_PLUGIN_ERR
Authentication plugin '%s' reported error: %s
|
1251
|
Client doesn't support auth protocol
ER_NOT_SUPPORTED_AUTH_MODE
Client does not support authentication protocol requested by server; consider upgrading MySQL client
|
3159
|
Insecure transport prohibited
ER_SECURE_TRANSPORT_REQUIRED
Connections using insecure transport are prohibited while --require_secure_transport=ON.
|
1158
|
Error reading communication packets
ER_NET_READ_ERROR
Got an error reading communication packets
|
1159
|
Got timeout reading communication packets
ER_NET_READ_INTERRUPTED
Got timeout reading communication packets
|
4031
|
Disconnected by the server for inactivity
ER_CLIENT_INTERACTION_TIMEOUT
The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.
|
Access and privileges
| Code | Meaning |
|---|---|
1045
|
Access denied for user
ER_ACCESS_DENIED_ERROR
Access denied for user '%s'@'%s' (using password: %s)
|
1044
|
Access denied for user to database
ER_DBACCESS_DENIED_ERROR
Access denied for user '%s'@'%s' to database '%s'
|
1130
|
Host is not allowed to connect
ER_HOST_NOT_PRIVILEGED
Host '%s' is not allowed to connect to this MySQL server
|
1698
|
Access denied for user (no password)
ER_ACCESS_DENIED_NO_PASSWORD_ERROR
Access denied for user '%s'@'%s'
|
1142
|
Command denied to user for table
ER_TABLEACCESS_DENIED_ERROR
%s command denied to user '%s'@'%s' for table '%s'
|
1143
|
Command denied to user for column
ER_COLUMNACCESS_DENIED_ERROR
%s command denied to user '%s'@'%s' for column '%s' in table '%s'
|
1227
|
Access denied; you need a privilege
ER_SPECIFIC_ACCESS_DENIED_ERROR
Access denied; you need (at least one of) the %s privilege(s) for this operation
|
1396
|
Operation CREATE USER failed
ER_CANNOT_USER
Operation %s failed for %s
|
1419
|
SUPER privilege needed with binary logging
ER_BINLOG_CREATE_ROUTINE_NEED_SUPER
You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
|
1449
|
Definer user does not exist
ER_NO_SUCH_USER
The user specified as a definer ('%s'@'%s') does not exist
|
Syntax and statements
| Code | Meaning |
|---|---|
1064
|
You have an error in your SQL syntax
ER_PARSE_ERROR
%s near '%s' at line %d
|
1149
|
SQL syntax error
ER_SYNTAX_ERROR
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
|
1052
|
Column is ambiguous
ER_NON_UNIQ_ERROR
Column '%s' in %s is ambiguous
|
1055
|
Expression isn't in GROUP BY
ER_WRONG_FIELD_WITH_GROUP
'%s' isn't in GROUP BY
|
1093
|
Can't specify target table for update
ER_UPDATE_TABLE_USED
You can't specify target table '%s' for update in FROM clause
|
1136
|
Column count doesn't match value count
ER_WRONG_VALUE_COUNT_ON_ROW
Column count doesn't match value count at row %ld
|
1242
|
Subquery returns more than 1 row
ER_SUBQUERY_NO_1_ROW
Subquery returns more than 1 row
|
1248
|
Every derived table must have its own alias
ER_DERIVED_MUST_HAVE_ALIAS
Every derived table must have its own alias
|
1318
|
Incorrect number of arguments
ER_SP_WRONG_NO_OF_ARGS
Incorrect number of arguments for %s %s; expected %u, got %u
|
Databases, tables and columns
| Code | Meaning |
|---|---|
1049
|
Unknown database
ER_BAD_DB_ERROR
Unknown database '%s'
|
1046
|
No database selected
ER_NO_DB_ERROR
No database selected
|
1054
|
Unknown column in field list
ER_BAD_FIELD_ERROR
Unknown column '%s' in '%s'
|
1146
|
Table doesn't exist
ER_NO_SUCH_TABLE
Table '%s.%s' doesn't exist
|
1050
|
Table already exists
ER_TABLE_EXISTS_ERROR
Table '%s' already exists
|
1051
|
Unknown table
ER_BAD_TABLE_ERROR
Unknown table '%s'
|
1060
|
Duplicate column name
ER_DUP_FIELDNAME
Duplicate column name '%s'
|
1091
|
Can't DROP; check that column/key exists
ER_CANT_DROP_FIELD_OR_KEY
Can't DROP '%s'; check that column/key exists
|
1305
|
Function or procedure does not exist
ER_SP_DOES_NOT_EXIST
%s %s does not exist
|
1442
|
Trigger can't update its own table
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
Can't update table '%s' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
|
Keys and constraints
| Code | Meaning |
|---|---|
1062
|
Duplicate entry for key
ER_DUP_ENTRY
Duplicate entry '%s' for key %d
|
1061
|
Duplicate key name
ER_DUP_KEYNAME
Duplicate key name '%s'
|
1452
|
Foreign key fails: cannot add child row
ER_NO_REFERENCED_ROW_2
Cannot add or update a child row: a foreign key constraint fails%s
|
1451
|
Foreign key fails: cannot delete parent row
ER_ROW_IS_REFERENCED_2
Cannot delete or update a parent row: a foreign key constraint fails%s
|
1216
|
Cannot add or update a child row
ER_NO_REFERENCED_ROW
Cannot add or update a child row: a foreign key constraint fails
|
1217
|
Cannot delete or update a parent row
ER_ROW_IS_REFERENCED
Cannot delete or update a parent row: a foreign key constraint fails
|
1215
|
Cannot add foreign key constraint
ER_CANNOT_ADD_FOREIGN
Cannot add foreign key constraint
|
3780
|
Foreign key columns are incompatible
ER_FK_INCOMPATIBLE_COLUMNS
Referencing column '%s' and referenced column '%s' in foreign key constraint '%s' are incompatible.
|
1822
|
Missing index for foreign key constraint
ER_FK_NO_INDEX_PARENT
Failed to add the foreign key constraint. Missing index for constraint '%s' in the referenced table '%s'
|
1824
|
Failed to open the referenced table
ER_FK_CANNOT_OPEN_PARENT
Failed to open the referenced table '%s'
|
1048
|
Column cannot be null
ER_BAD_NULL_ERROR
Column '%s' cannot be null
|
3819
|
Check constraint is violated
ER_CHECK_CONSTRAINT_VIOLATED
Check constraint '%s' is violated.
|
1071
|
Specified key was too long
ER_TOO_LONG_KEY
Specified key was too long; max key length is %d bytes
|
1075
|
Only one auto column, and it must be a key
ER_WRONG_AUTO_KEY
Incorrect table definition; there can be only one auto column and it must be defined as a key
|
1701
|
Can't truncate a table with foreign keys
ER_TRUNCATE_ILLEGAL_FK
Cannot truncate a table referenced in a foreign key constraint (%s)
|
1586
|
Duplicate entry for key (with key name)
ER_DUP_ENTRY_WITH_KEY_NAME
Duplicate entry '%s' for key '%s'
|
1826
|
Duplicate foreign key constraint name
ER_FK_DUP_NAME
Duplicate foreign key constraint name '%s'
|
Data values
| Code | Meaning |
|---|---|
1364
|
Field doesn't have a default value
ER_NO_DEFAULT_FOR_FIELD
Field '%s' doesn't have a default value
|
1366
|
Incorrect value for column
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
Incorrect %s value: '%s' for column '%s' at row %ld
|
1406
|
Data too long for column
ER_DATA_TOO_LONG
Data too long for column '%s' at row %ld
|
1292
|
Truncated incorrect value
ER_TRUNCATED_WRONG_VALUE
Truncated incorrect %s value: '%s'
|
1264
|
Out of range value for column
ER_WARN_DATA_OUT_OF_RANGE
Out of range value for column '%s' at row %ld
|
1265
|
Data truncated for column
WARN_DATA_TRUNCATED
Data truncated for column '%s' at row %ld
|
1067
|
Invalid default value
ER_INVALID_DEFAULT
Invalid default value for '%s'
|
Transactions and locking
| Code | Meaning |
|---|---|
1205
|
Lock wait timeout exceeded
ER_LOCK_WAIT_TIMEOUT
Lock wait timeout exceeded; try restarting transaction
|
1213
|
Deadlock found when trying to get lock
ER_LOCK_DEADLOCK
Deadlock found when trying to get lock; try restarting transaction
|
3572
|
Lock couldn't be acquired with NOWAIT
ER_LOCK_NOWAIT
Statement aborted because lock(s) could not be acquired immediately and NOWAIT is set.
|
1206
|
Locks exceed the lock table size
ER_LOCK_TABLE_FULL
The total number of locks exceeds the lock table size
|
1792
|
Write in a READ ONLY transaction
ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION
Cannot execute statement in a READ ONLY transaction.
|
3024
|
Maximum statement execution time exceeded
ER_QUERY_TIMEOUT
Query execution was interrupted, maximum statement execution time exceeded
|
Server limits and settings
| Code | Meaning |
|---|---|
1040
|
Too many connections
ER_CON_COUNT_ERROR
Too many connections
|
1203
|
User has more than max_user_connections
ER_TOO_MANY_USER_CONNECTIONS
User %s already has more than 'max_user_connections' active connections
|
1153
|
Got a packet bigger than max_allowed_packet
ER_NET_PACKET_TOO_LARGE
Got a packet bigger than 'max_allowed_packet' bytes
|
1175
|
Safe update mode blocked the statement
ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. %s
|
1290
|
Server option prevents this statement
ER_OPTION_PREVENTS_STATEMENT
The MySQL server is running with the %s option so it cannot execute this statement
|
1114
|
The table is full
ER_RECORD_FILE_FULL
The table '%s' is full
|
A faster way to work with MySQL
SQLly is a native SQL client for macOS, Windows and Linux with schema-aware IntelliSense and guardrails for risky statements.