MySQL Database Errors
Every common MySQL and MariaDB failure in one place: a syntax error that rejects your statement, access denied on connect, the server out of connection slots, a duplicate-entry collision, a deadlock or lock-wait timeout. Each guide opens with the direct cause, then the exact SQL and shell commands to confirm and fix it. Start with the fastest path below, or paste your own error into the assistant.
Fix your error now
Paste the error or logs and let the Incident Assistant diagnose it, or run a guided triage prompt with AI — no copy-paste.
Every guide in this cluster
50 guides-
'You have an error in your SQL syntax' — Fix ERROR 1064
Fix MySQL ERROR 1064 'You have an error in your SQL syntax': reserved words, quoting, version-specific syntax, and hidden characters. Read the near hint.
-
'ERROR 1045 (28000)' Access Denied for User
Fix MySQL ERROR 1045 (28000) Access denied for user: diagnose wrong passwords, host-mismatched grants, auth plugin issues, anonymous users, and missing privileges.
-
'ERROR 1040 (HY000)' Too Many Connections
Fix MySQL ERROR 1040 Too many connections: diagnose exhausted max_connections, leaked pool connections, sleeping threads, low limits, and per-user caps.
-
'ERROR 1062 (23000)' Duplicate Entry for Key
Fix MySQL ERROR 1062 Duplicate entry for key: diagnose unique-key collisions, retries, auto_increment resets, case/collation surprises, and replication conflicts.
-
'Access denied for user root@localhost' — Fix ERROR 1698
Fix MySQL ERROR 1698 'Access denied for root@localhost': the account uses auth_socket, not a password. Log in as the OS user or switch the plugin safely.
-
'Cannot add or update a child row: a foreign key constraint fails' — Fix 1452
Fix MySQL error 1452 'Cannot add or update a child row: a foreign key constraint fails': find the missing parent row, fix insert order, type/charset mismatches, and orphaned data safely.
-
'Cannot delete or update a parent row' — Fix ERROR 1451
Fix MySQL ERROR 1451 'Cannot delete or update a parent row': a foreign key still references it. Delete children, pick the right ON DELETE, or reparent.
-
'command denied to user' — Fix ERROR 1142
Fix MySQL ERROR 1142 'command denied to user': the account authenticated but lacks the privilege on that object. Grant least-privilege access precisely.
-
'Data too long for column' — Fix ERROR 1406
Fix MySQL ERROR 1406 'Data too long for column': the value exceeds the length or multibyte encoding inflates its bytes. Resize, fix charset, or validate.
-
'errno 150 Cannot add foreign key constraint' — Fix Mismatched Keys
Fix MySQL error 1215 'Cannot add foreign key constraint': mismatched column types, missing indexes, engine or charset differences, and orphaned data that blocks FK creation.
-
'ERROR 1038 (HY001)' Out of Sort Memory, Consider Increasing Server Sort Buffer Size
Fix MySQL ERROR 1038 Out of sort memory: large ORDER BY/GROUP BY sorts, oversized sort_buffer_size, wide row sorts, and missing indexes causing filesort failures.
-
'ERROR 1054 (42S22)' Unknown Column in Field List
Fix MySQL ERROR 1054 Unknown column in field list: typos, missing migrations, wrong alias scope, GROUP BY on aliases, and reserved words causing column resolution failures.
-
'ERROR 1114 (HY000)' The Table Is Full
Fix MySQL ERROR 1114 The table is full: diagnose a full disk, exhausted tmp space, MEMORY table limits, capped tablespaces, and per-partition limits in InnoDB.
-
'ERROR 1146 (42S02)' Table Doesn't Exist
Fix MySQL ERROR 1146 Table doesn't exist: diagnose wrong database, case-sensitive names, missing migrations, dropped or orphaned InnoDB tables, and bad grants.
-
'ERROR 1153 (08S01)' Got a Packet Bigger Than max_allowed_packet
Fix MySQL ERROR 1153 Got a packet bigger than max_allowed_packet: oversized BLOBs, large inserts, mysqldump restores, and client/server packet size mismatches.
-
'ERROR 1194 (HY000)' Table Is Marked as Crashed and Should Be Repaired (MyISAM)
Fix MySQL ERROR 1194 Table is marked as crashed: MyISAM corruption from crashes, full disk, or ungraceful shutdown. Repair with REPAIR TABLE and myisamchk safely.
-
'ERROR 1205 (HY000)' Lock Wait Timeout Exceeded
Fix MySQL ERROR 1205 Lock wait timeout exceeded: diagnose long-running transactions, idle transactions holding locks, hot rows, and uncommitted writes in InnoDB.
-
'ERROR 1206 (HY000)' The Total Number of Locks Exceeds the Lock Table Size
Fix MySQL ERROR 1206 total number of locks exceeds the lock table size: huge transactions, unindexed bulk DELETE/UPDATE, and undersized buffer pool in InnoDB.
-
'ERROR 1213 (40001)' Deadlock Found
Fix MySQL ERROR 1213 Deadlock found when trying to get lock: diagnose lock-ordering cycles, gap locks, hot rows, and missing indexes in InnoDB with retry logic.
-
'ERROR 1236 (HY000)' Got Fatal Error 1236 From Source When Reading Binlog
Fix MySQL replication ERROR 1236 Got fatal error 1236 from source: purged binlogs, missing GTIDs, corrupt binary logs, and binlog position drift on replicas.
-
'ERROR 1366 (HY000)' Incorrect String Value for Column (utf8 vs utf8mb4)
Fix MySQL ERROR 1366 Incorrect string value: 4-byte emoji into utf8 columns, charset mismatches, and connection encoding issues. Migrate to utf8mb4 safely.
-
'ERROR 2002 (HY000)' Can't Connect Through Socket
Fix MySQL ERROR 2002 Can't connect to local MySQL server through socket: diagnose a stopped server, wrong socket path, permissions, and crashed mysqld.
-
'ERROR 2003 (HY000)' Can't Connect to MySQL Server (10061/111)
Fix MySQL ERROR 2003 Can't connect to MySQL server over TCP: server down, wrong port, firewall, bind-address, and skip-networking causing connection refused.
-
'ERROR 2006 (HY000)' MySQL Server Has Gone Away
Fix MySQL ERROR 2006 server has gone away: diagnose wait_timeout drops, oversized packets, a crashed or OOM-killed server, and stale pooled connections.
-
'Got an error reading communication packets' Aborted Connections
Fix MySQL Got an error reading communication packets: aborted connections from timeouts, killed clients, max_allowed_packet, and network drops. Diagnose Aborted_clients.
-
'Host is blocked because of many connection errors' — Unblock & Fix
Fix MySQL error 1129 'Host is blocked because of many connection errors': unblock with FLUSH HOSTS, find the misbehaving client, and tune max_connect_errors so it stays fixed.
-
'Incorrect datetime value' — Fix ERROR 1292
Fix MySQL ERROR 1292 'Incorrect datetime value': zero dates, bad formats, and DST gaps. Store valid values and align sql_mode and formats to stop it.
-
'isn't in GROUP BY' — Fix ERROR 1055 only_full_group_by
Fix MySQL ERROR 1055 only_full_group_by: nonaggregated columns not in GROUP BY. Rewrite with aggregates, ANY_VALUE, or the PK instead of disabling it.
-
'Lost connection to MySQL server during query' — Fix Dropped Queries
Fix MySQL error 2013 'Lost connection during query': timeouts, oversized packets, OOM kills, network drops, and long-running statements that break mid-execution.
-
'Out of range value for column' — Fix ERROR 1264
Fix MySQL ERROR 1264 'Out of range value for column': integer overflow, unsigned negatives, and decimal limits. Pick a bigger type and validate input.
-
'server is running with the --read-only option' — Fix Read-Only Writes
Fix MySQL error 1290 'running with the --read-only option so it cannot execute this statement': confirm you're on a replica, find stale writes, and clear read_only safely after failover.
-
'Specified key was too long; max key length is 767 bytes' — Fix Index Limits
Fix MySQL error 1071 'Specified key was too long': byte vs character limits under utf8mb4, the 767 and 3072 byte caps, prefix indexes, and the innodb_large_prefix setting.
-
'Table already exists' — Fix ERROR 1050
Fix MySQL ERROR 1050 'Table already exists': rerun migrations, orphaned tablespaces, and case-sensitivity. Make DDL idempotent and reconcile schema state.
-
'ERROR 1032 (HY000): Can't find record' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1032 (HY000) Can't find record: replica data drift on row-based replication. Diagnose with mysqlbinlog and resync safely.
-
'ERROR 1044 (42000): Access denied for user to database' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1044 (42000) Access denied for user to database: missing GRANTs, wrong host account, and forgotten FLUSH PRIVILEGES.
-
'ERROR 1067 (42000): Invalid default value' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1067 (42000) Invalid default value: zero dates under strict sql_mode, DEFAULT on TEXT/BLOB, and CURRENT_TIMESTAMP limits.
-
'ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1075 there can be only one auto column and it must be defined as a key: unindexed AUTO_INCREMENT and composite-key ordering.
-
'ERROR 1093 (HY000): You can't specify target table for update in FROM clause' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1093 (HY000) You can't specify target table for update in FROM clause: wrap the subquery in a derived table or use a JOIN.
-
'ERROR 1118 (42000): Row size too large' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1118 (42000) Row size too large: too many VARCHAR/TEXT columns, wrong row_format, and the 8KB InnoDB page limit.
-
'ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1130 (HY000) Host is not allowed to connect: missing host grant, bind-address, and skip_name_resolve gotchas.
-
'ERROR 1136 (21S01): Column count doesn't match value count at row 1' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1136 (21S01) Column count doesn't match value count: INSERT column/value mismatch, implicit column lists, and bad CSV loads.
-
'ERROR 1170 (42000): BLOB/TEXT column used in key specification without a key length' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1170 (42000) BLOB/TEXT column used in key specification without a key length: add a prefix length or use a generated column.
-
'ERROR 1305 (42000): FUNCTION does not exist' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1305 (42000) FUNCTION does not exist: space before parenthesis, missing schema qualifier, and version-specific built-ins.
-
'ERROR 144: Table is marked as crashed and last (automatic?) repair failed' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 144 Table is marked as crashed and last repair failed: MyISAM corruption where auto-repair gave up. Repair with myisamchk safely.
-
'ERROR 1449 (HY000): The user specified as a definer does not exist' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1449 (HY000) The user specified as a definer does not exist: recreate the definer, change DEFINER, or use SQL SECURITY INVOKER.
-
'ERROR 1615 (HY000): Prepared statement needs to be re-prepared' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1615 (HY000) Prepared statement needs to be re-prepared: metadata changes, low table_definition_cache, and retry logic.
-
'ERROR 1927 (HY000): Connection was killed' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 1927 (HY000) Connection was killed: KILL statements, failovers, max_statement_time, and OOM/restart events.
-
'ERROR 2005 (HY000): Unknown MySQL server host' — Cause, Fix, and Troubleshooting Guide
Fix MySQL ERROR 2005 (HY000) Unknown MySQL server host: DNS resolution failures, typos in --host, and stale service/hostnames.
-
'Got error 28 from storage engine' — Cause, Fix, and Troubleshooting Guide
Fix MySQL 'Got error 28 from storage engine': the data disk or tmpdir is full. Free space, relocate tmpdir, and prevent recurrence.
-
'InnoDB: page_cleaner: 1000ms intended loop took ... ms' — Cause, Fix, and Troubleshooting Guide
Fix MySQL 'InnoDB: page_cleaner: 1000ms intended loop took 4013ms': flushing can't keep up. Tune io_capacity, lru_scan_depth, and dirty-page limits.
MySQL AI prompts
Copy-paste, production-safe prompts for this stack.
More MySQL guides
Every MySQL prompt and troubleshooting guide.
Frequently asked questions
How do I fix MySQL ERROR 1064 (SQL syntax)?
Why do I get "Access denied for user" (ERROR 1045) in MySQL?
user@localhost and user@% are different accounts; verify the host pattern, the password, and the authentication plugin. See ERROR 1045 access denied.How do I resolve "Too many connections" in MySQL?
max_connections. Find and kill idle/long-running sessions with SHOW PROCESSLIST, raise max_connections if the host has headroom, and fix the real cause — a connection leak or an undersized pool. See too many connections.