// MySQL error reference

MySQL error 1406: Data too long for column

A string or binary value is longer than the column allows, for example 300 characters into VARCHAR(255). Widen the column or shorten the value.

Error number
1406
Name
ER_DATA_TOO_LONG
SQLSTATE
22001
Category
Data values
Error message
Data too long for column '%s' at row %ld

What it means

The value exceeds the column's declared length (in characters for text types, bytes for binary types). In strict mode the statement fails with 1406 and names the column and row. In non-strict mode MySQL truncates the value and only warns (1265).

Common causes

  • User input longer than the column, such as a long name or URL.
  • A VARCHAR sized for single-byte data that now holds longer text.
  • Inserting into a TEXT column more than its 65,535-byte limit (use MEDIUMTEXT).
  • A BIT or BINARY column given more bits or bytes than it holds.

How to fix it

  1. Find the longest value you need to store, then widen the column.

    ALTER TABLE customers MODIFY website VARCHAR(2048);
  2. Or validate and shorten values in the application before inserting.

Reproduce it safely

CREATE TEMPORARY TABLE t (code VARCHAR(3));
INSERT INTO t VALUES ('ABCD');  -- ERROR 1406 (22001): Data too long for column 'code' at row 1

Related errors

More data values errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.