🐬 MySQL errors

MySQL and MariaDB error codes like 1045, 1064, 1146 and 2002.

CodeErrorWhat it means
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.
caching_sha2_password Authentication plugin 'caching_sha2_password' cannot be loaded An old MySQL client/driver can’t use MySQL 8’s default authentication plugin.
MySQL won't start Job for mysql.service failed because the control process exited with error code The MySQL/MariaDB service failed to start — the real reason is in the MySQL error log.
1005 MySQL ERROR 1005 (HY000): Can't create table (errno: 150 "Foreign key constraint is incorrectly formed") A foreign key definition is invalid — the referenced column’s type, index or charset doesn’t match.
1007 MySQL ERROR 1007 (HY000): Can't create database 'x'; database exists CREATE DATABASE ran for a database that already exists.
1008 MySQL ERROR 1008 (HY000): Can't drop database 'x'; database doesn't exist DROP DATABASE targeted a database that isn’t there.
1022 MySQL ERROR 1022 (23000): Can't write; duplicate key in table An ALTER/CREATE produced a duplicate key or constraint name — often a foreign key name that already exists in…
1040 MySQL ERROR 1040 (08004): Too many connections MySQL reached `max_connections` and refuses new clients.
1044 MySQL ERROR 1044 (42000): Access denied for user to database The login succeeded, but the user has no privileges on the database you’re using.
1046 MySQL ERROR 1046 (3D000): No database selected A query referenced tables without a database selected (no USE and no db in the connection).
1048 MySQL ERROR 1048 (23000): Column 'x' cannot be null An INSERT/UPDATE put NULL into a NOT NULL column.
1049 MySQL ERROR 1049 (42000): Unknown database 'x' The database named in the connection doesn’t exist on that server.
1051 MySQL ERROR 1051 (42S02): Unknown table 'x' DROP TABLE targeted a table that doesn’t exist.
1054 MySQL ERROR 1054 (42S22): Unknown column in 'field list' The query references a column that doesn’t exist in the table (or an unquoted string being read as a column).
1060 MySQL ERROR 1060 (42S21): Duplicate column name 'x' A CREATE/ALTER adds a column that already exists, or a SELECT in a view/derived table produces two columns wi…
1061 MySQL ERROR 1061 (42000): Duplicate key name 'x' CREATE INDEX/ADD INDEX used an index name that already exists on the table.
1062 MySQL ERROR 1062 (23000): Duplicate entry for key An INSERT/UPDATE would create a duplicate value in a PRIMARY or UNIQUE key.
1064 MySQL ERROR 1064 (42000): You have an error in your SQL syntax MySQL couldn’t parse the query. The text after “near” shows where parsing failed.
1067 MySQL ERROR 1067 (42000): Invalid default value for 'created_at' A column’s DEFAULT isn’t allowed in the current SQL mode — classically '0000-00-00 00:00:00' with NO_ZERO_DAT…
1071 MySQL ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes An index on a VARCHAR is too long for the row format — classic with utf8mb4 VARCHAR(255) on MySQL 5.6/MariaDB…
1075 MySQL ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key An AUTO_INCREMENT column isn’t indexed (or there are two auto-increment columns).
1091 MySQL ERROR 1091 (42000): Can't DROP 'x'; check that column/key exists ALTER TABLE tried to drop a column or index that doesn’t exist.
1093 MySQL ERROR 1093 (HY000): You can't specify target table 'x' for update in FROM clause An UPDATE/DELETE uses a subquery that reads from the same table, which MySQL doesn’t allow directly.
1114 MySQL ERROR 1114 (HY000): The table 'x' is full MySQL couldn’t extend the table — disk full, a size limit, or a MEMORY table hitting max_heap_table_size.
1130 MySQL ERROR 1130 (HY000): Host 'x' is not allowed to connect to this MySQL server No MySQL account exists for the host you’re connecting from.
1142 MySQL ERROR 1142 (42000): SELECT command denied to user 'x'@'host' for table 'y' The account lacks the privilege for that statement on that table.
1146 MySQL ERROR 1146 (42S02): Table 'db.table' doesn't exist The query references a table that MySQL can’t find in that database.
1153 MySQL ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes A single statement or row exceeded max_allowed_packet — big BLOBs, huge INSERTs or large dump lines.
1175 MySQL ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column MySQL Workbench’s safe updates mode blocked an UPDATE/DELETE without a key-based WHERE.
1213 MySQL ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction MySQL detected a deadlock between two transactions and rolled one back.
1215 MySQL ERROR 1215 (HY000): Cannot add foreign key constraint The foreign key can’t be created — mismatched column types, missing index, or incompatible engines/collations.
1227 MySQL ERROR 1227 (42000): Access denied; you need (at least one of) the SUPER privilege(s) for this operation The import or statement needs SUPER/SYSTEM_VARIABLES_ADMIN — typical with dumps containing DEFINER clauses or…
1241 MySQL ERROR 1241 (21000): Operand should contain 1 column(s) A subquery or expression returned several columns where only one is expected.
126 incorrect key file MySQL ERROR 126 (HY000): Incorrect key file for table; try to repair it MySQL can’t use a table’s index file — usually a full tmp disk during a query, or MyISAM corruption.
1264 MySQL ERROR 1264 (22003): Out of range value for column 'x' at row 1 A number is too large (or negative for UNSIGNED) for the column type.
Unknown collation MySQL ERROR 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci' A dump from MySQL 8 uses a collation the target server (MySQL 5.7 / MariaDB) doesn’t support.
1292 MySQL ERROR 1292 (22007): Incorrect datetime value: 'x' for column 'y' A string couldn’t be converted to DATE/DATETIME — wrong format, empty string, or a zero date in strict mode.
1366 MySQL ERROR 1366 (HY000): Incorrect integer value: '' for column 'x' at row 1 An empty string or non-numeric text was inserted into an INT column under strict mode.
1366 MySQL ERROR 1366: Incorrect string value: '\xF0\x9F\x98\x80' for column The text contains characters (usually emoji) that the column’s character set can’t store — the column or conn…
1406 MySQL ERROR 1406: Data too long for column The value is longer than the column allows (e.g. 300 characters into VARCHAR(255)), and strict mode rejects i…
1418 MySQL ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled Creating a stored function failed because binary logging requires it to declare its data access characteristi…
1451 MySQL ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails You tried to delete/update a row that other rows still reference.
1452 MySQL ERROR 1452: Cannot add or update a child row: a foreign key constraint fails You inserted/updated a row whose foreign key value doesn’t exist in the referenced parent table.
1690 MySQL ERROR 1690 (22003): BIGINT UNSIGNED value is out of range Arithmetic on UNSIGNED columns produced a negative result.
1698 MySQL ERROR 1698 (28000): Access denied for user 'root'@'localhost' root uses the auth_socket/unix_socket plugin (Ubuntu/Debian default), so password logins as root fail.
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 i…
2003 MySQL ERROR 2003 (HY000): Can't connect to MySQL server on 'host:3306' (111) The client couldn’t reach MySQL over TCP — server down, wrong host/port, firewall, or MySQL bound to localhos…
2006 MySQL ERROR 2006 (HY000): MySQL server has gone away The connection to MySQL was closed — usually by a timeout or a packet larger than `max_allowed_packet`.
2013 MySQL ERROR 2013 (HY000): Lost connection to MySQL server during query The connection dropped mid-query — server crash/restart, timeouts, or a proxy cutting long queries.
3780 MySQL ERROR 3780 (HY000): Referencing column 'x' and referenced column 'y' in foreign key constraint are incompatible. MySQL 8 refuses a foreign key between columns of different types or collations.