mysqldude
Error codes › 1406

MySQL & MariaDB error 1406: Data too long for column

Error messageData too long for column '…' at row …
Example from our test runs: Data too long for column 'name' at row 1 (8.0.46)

A string or binary value is longer than the column allows. In strict mode it is rejected; without strict mode it would be silently cut off.

MySQLMariaDB
SymbolER_DATA_TOO_LONGER_DATA_TOO_LONG
SQLSTATE2200122001
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

Data too long for column 'code' at row 1: the column is VARCHAR(5) (or CHAR, BINARY, TEXT …) and the value is longer. Lengths are in characters for text columns and bytes for binary ones.

With strict mode (STRICT_TRANS_TABLES, the default since MySQL 5.7 and in MariaDB) the statement fails. Without it, the value is truncated with warning 1265. On MySQL 5.6, whose default was non-strict, that is how data quietly lost its last characters for years.

Why it happens

  • Input longer than the schema expected: names, URLs, user agents, JSON.
  • Moving an application from MySQL 5.6 (non-strict) to 5.7+/MariaDB: inserts that used to be truncated now fail.
  • Fixed-width LOAD DATA … FIELDS TERMINATED BY '' into a utf8mb4 table: the field widths are computed for the wider character set and every row fails with 1406 on MySQL 8.0+ and MariaDB. See our fixed-width import guide.

How to fix it

  • Widen the column: ALTER TABLE c MODIFY code VARCHAR(20); (or TEXT for unbounded text).
  • Validate length in the application before inserting.
  • Don’t fix it by switching strict mode off: that turns the error back into silent truncation.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE c (code VARCHAR(5));
  2. Run:

    INSERT INTO c VALUES ('ABCDEFG');

You get: Data too long for column 'code' at row 1(11.8.9)

Verified fixes

  1. Widen the column (or validate input length in the application)

    ALTER TABLE c MODIFY code VARCHAR(20);
    INSERT INTO c VALUES ('ABCDEFG');
    SELECT code FROM c;

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Insert a value longer than the column (strict mode)
repro
≠✓ 1406✓ 1406✓ 1406✓ 1406✓ 1406✓ 1406✓ 1406✓ 1406
Without strict mode the value is silently cut to fit (warning 1265)
version check
⚠ 1265⚠ 3090,1265⚠ 1265⚠ 1265⚠ 1265⚠ 1265⚠ 1265⚠ 1265⚠ 1265
Widen the column (or validate input length in the application)
fix
✓✓✓✓✓✓✓✓✓
Insert a value longer than the column (strict mode) repro
MySQL 5.6≠5.7✓ 14068.0✓ 14068.4✓ 14069✓ 1406
MariaDB 10.6✓ 140610.11✓ 140611.4✓ 140611.8✓ 1406
Without strict mode the value is silently cut to fit (warning 1265) version check
MySQL 5.6⚠ 12655.7⚠ 3090,12658.0⚠ 12658.4⚠ 12659⚠ 1265
MariaDB 10.6⚠ 126510.11⚠ 126511.4⚠ 126511.8⚠ 1265
Widen the column (or validate input length in the application) fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9
What the warnings and failures say (3)
  • Insert a value longer than the column (strict mode) (MySQL 5.6): expected error 1406 did not occur
  • Without strict mode the value is silently cut to fit (warning 1265) (MySQL 5.6, MySQL 8.0, MySQL 8.4, MySQL 9, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): warning 1265: Data truncated for column 'code' at row 1
  • Without strict mode the value is silently cut to fit (warning 1265) (MySQL 5.7): warning 3090: Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.; warning 1265: Data truncated for column 'code' at row 1

Related errors

  • 1366 ER_TRUNCATED_WRONG_VALUE_FOR_FIELDexplained
  • 1265 WARN_DATA_TRUNCATEDexplained
  • 1264 ER_WARN_DATA_OUT_OF_RANGEexplained

Where this error shows up in our guides