MySQL rejects an INSERT with Data too long for column
ERROR 1406 (22001): Data too long for column 'description' at row 1Short answer
In strict mode, MySQL refuses a value longer than the column allows instead of cutting it. Find the column's real limit, then either shorten the data or widen the column. A TEXT column holds 65,535 bytes; MEDIUMTEXT and LONGTEXT hold far more. Limits are in bytes for TEXT, so multibyte text fits less.
Fix it fast
1Find out which cause you have
Look up the declared type of the column named in the error, and measure the value you tried to insert.
SHOW COLUMNS FROM products LIKE 'description'; SELECT CHAR_LENGTH('your text'), LENGTH('your text');2Match what you see, then jump to its fix
What does the error look like?
ERROR 1406 (22001): Data too long for column 'description' at row 1ER_DATA_TOO_LONG: Data too long for column '%s' at row %ld
Cause 1 of 2
The VARCHAR or CHAR column is shorter than the data
1Check
A VARCHAR(M) holds at most M characters. In strict mode, cutting non-space characters is an error and the row is not inserted. Compare CHAR_LENGTH of the value with M.
SELECT MAX(CHAR_LENGTH(description)) FROM staging_products;2Fix
Widen the column. MODIFY needs the full definition, because attributes you leave out are not carried forward.
ALTER TABLE products
MODIFY description VARCHAR(1000) NOT NULL DEFAULT '';3Verify
Repeat the INSERT that failed.
SHOW COLUMNS FROM products LIKE 'description';Confirmed by dev.mysql.com
Cause 2 of 2
The text is bigger than a TEXT column's byte limit
1Check
TINYTEXT holds 255 bytes, TEXT 65,535, MEDIUMTEXT 16,777,215 and LONGTEXT 4,294,967,295. These are bytes, so utf8mb4 text with emoji or non-Latin letters fits fewer characters than the number suggests.
SELECT MAX(LENGTH(body)) AS bytes FROM staging_articles;2Fix
Change the column to a type that holds the largest value you expect.
ALTER TABLE articles
MODIFY body MEDIUMTEXT NOT NULL;3Verify
The failed statement now succeeds.
SHOW COLUMNS FROM articles LIKE 'body';Confirmed by dev.mysql.com
How do I stop it coming back?
- Validate length in the application before the INSERT and show the user a clear message.
- Keep strict mode on: with it off, MySQL silently truncates and only raises a warning, so you lose data without noticing.
- Size columns from real data (MAX of LENGTH) with some headroom, not from a guess.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
MySQL refuses or trims a value: Data truncated for column
Data truncated for column 'status' at row 1
MySQL reports truncation when a value does not fit the column.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver fails to resolve Maven dependencies when downloading a database driver
A driver library does not download automatically
DBeaver downloads driver jars from a Maven repository.
3 causes, each with a fix