MariaDB / MySQL Error Code Reference

Every significant MariaDB and MySQL error number explained — what it means, why it happens, and how to fix it. SQL trigger examples and fixes included for every entry.

⚙️ Error examples are AI-generated to help developers and are subject to the occasional error. Always verify against your specific version and setup.

47 of 47 errors1 critical47 HIGH confidence
1044

Access denied for user to database

Access Control

1045

Access denied for user (using password)

Access Control

1046

No database selected

Connection

1048

Column cannot be null

Constraint Violation

1049

Unknown database

Schema

1050

Table already exists

Schema

1051

Unknown table

Schema

1054

Unknown column in field list

Schema

1062

Duplicate entry for key

Integrity Constraint Violation

1064

You have an error in your SQL syntax

Syntax Error

1071

Specified key was too long; max key length is 767 bytes

Schema

1114

The table is full

Resource Limit

1136

Column count doesn't match value count

Syntax Error

1146

Table doesn't exist

Schema

1153

Got a packet bigger than 'max_allowed_packet' bytes

Resource Limit

1175

You are using safe update mode and tried to update a table without a WHERE using a KEY column

Safety

1205

Lock wait timeout exceeded; try restarting transaction

Locking & Concurrency

1213

Deadlock found when trying to get lock; try restarting transaction

Locking & Concurrency

1215

Cannot add foreign key constraint

Schema

1216

Cannot add or update a child row: a foreign key constraint fails

Integrity Constraint Violation

1217

Cannot delete or update a parent row: a foreign key constraint fails

Integrity Constraint Violation

1264

Out of range value for column

Data Truncation

1292

Incorrect datetime value

Data Truncation

1366

Incorrect integer value for column

Data Truncation

1406

Data too long for column

Data Truncation

1040

Too many connections

Connection

1052

Column in field list is ambiguous

Query Syntax

1060

Duplicate column name

DDL

1067

Invalid default value for column

DDL

1068

Multiple primary key defined

DDL

1130

Host is not allowed to connect to this MySQL server

Access Control

1193

Unknown system variable

Configuration

1203

User has exceeded the max_user_connections resource

Connection

1222

The used SELECT statements have a different number of columns

Query Syntax

1227

Access denied; you need SUPER privilege for this operation

Access Control

1242

Subquery returns more than 1 row

Query Syntax

1248

Every derived table must have its own alias

Query Syntax

1265

Data truncated for column

Data Integrity

1267

Illegal mix of collations

Character Sets

1305

FUNCTION or PROCEDURE does not exist

Stored Routines

1364

Field doesn't have a default value

Data Integrity

1451

Cannot delete or update a parent row: a foreign key constraint fails

Referential Integrity

1452

Cannot add or update a child row: a foreign key constraint fails

Referential Integrity

2002

Can't connect to local MySQL server through socket

Connection

2003

Can't connect to MySQL server on host

Connection

2006

MySQL server has gone away

Connection

2013

Lost connection to MySQL server during query

Connection

About This Reference

This MariaDB error code reference covers 25 of the most common error numbers encountered in production MariaDB and MySQL deployments. Each entry includes the official error number, SQLSTATE code, a minimal trigger SQL example, a verified fix with mechanism explanation, and sources from the official MariaDB documentation. Errors span access control, schema issues, constraint violations, locking, and data type mismatches.