Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-12-01 · container image mysql:8.4
In strict mode (the MySQL 8.4 default) a string longer than VARCHAR(n) is not truncated; the statement fails with ERROR 1406. The message names the column and the row number where it happened.
The whole statement is rejected, so no rows are changed. The message stays in English even with Korean or Japanese lc_messages. Below are three causes verified on MySQL 8.4.
01The value is longer than VARCHAR(n)
phone is VARCHAR(11), sized for digits only. A number with dashes, 010-1234-5678, is 13 characters, so the INSERT fails.
Setup
CREATE TABLE members (id INT PRIMARY KEY, phone VARCHAR(11));Query OK, 0 rows affected (0.01 sec)INSERT INTO members VALUES (1, '010-1234-5678');ERROR 1406 (22001): Data too long for column 'phone' at row 1SELECT CHAR_LENGTH('010-1234-5678') AS len, CHARACTER_MAXIMUM_LENGTH AS max_len FROM information_schema.columns WHERE table_schema = 'lab_a' AND table_name = 'members' AND column_name = 'phone';+-----+---------+
| len | max_len |
+-----+---------+
| 13 | 11 |
+-----+---------+
1 row in set (0.00 sec)ALTER TABLE members MODIFY phone VARCHAR(20);Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0Comparing CHAR_LENGTH with CHARACTER_MAXIMUM_LENGTH shows 13 vs 11. Widen the column: ALTER TABLE members MODIFY phone VARCHAR(20). The same INSERT then succeeds.
INSERT INTO members VALUES (1, '010-1234-5678');
SELECT * FROM members;Query OK, 1 row affected (0.00 sec)
+----+---------------+
| id | phone |
+----+---------------+
| 1 | 010-1234-5678 |
+----+---------------+
1 row in set (0.00 sec)02An UPDATE with CONCAT makes the value longer
memo is VARCHAR(20). Appending ' [checked]' makes row 2 27 characters long, so the UPDATE fails at row 2. Row 1 (19 characters) is not updated either.
Setup
CREATE TABLE orders (id INT PRIMARY KEY, memo VARCHAR(20));
INSERT INTO orders VALUES (1, 'gift wrap'), (2, 'leave at the door');Query OK, 0 rows affected (0.02 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0UPDATE orders SET memo = CONCAT(memo, ' [checked]');ERROR 1406 (22001): Data too long for column 'memo' at row 2SELECT id, memo, CHAR_LENGTH(CONCAT(memo, ' [checked]')) AS new_len FROM orders ORDER BY id;+----+-------------------+---------+
| id | memo | new_len |
+----+-------------------+---------+
| 1 | gift wrap | 19 |
| 2 | leave at the door | 27 |
+----+-------------------+---------+
2 rows in set (0.01 sec)ALTER TABLE orders MODIFY memo VARCHAR(100);Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0Check the new length with CHAR_LENGTH(CONCAT(...)) before updating. Here the column was widened to VARCHAR(100) and the UPDATE changed both rows.
UPDATE orders SET memo = CONCAT(memo, ' [checked]');
SELECT * FROM orders ORDER BY id;Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
+----+-----------------------------+
| id | memo |
+----+-----------------------------+
| 1 | gift wrap [checked] |
| 2 | leave at the door [checked] |
+----+-----------------------------+
2 rows in set (0.00 sec)03INSERT ... SELECT into a shorter column
products.name is VARCHAR(100) but label_print.label is VARCHAR(20). One product name is 47 characters, so the copy fails at row 2.
Setup
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(100));
INSERT INTO products VALUES (1, 'USB cable'), (2, 'Wireless ergonomic keyboard with numeric keypad');
CREATE TABLE label_print (id INT PRIMARY KEY, label VARCHAR(20));Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.02 sec)INSERT INTO label_print (id, label) SELECT id, name FROM products;ERROR 1406 (22001): Data too long for column 'label' at row 2SELECT id, CHAR_LENGTH(name) AS len FROM products WHERE CHAR_LENGTH(name) > 20;+----+------+
| id | len |
+----+------+
| 2 | 47 |
+----+------+
1 row in set (0.00 sec)Find the long rows with CHAR_LENGTH(name) > 20. If cutting is acceptable, say so explicitly: SELECT id, LEFT(name, 20). Both rows are copied and the long name is cut to 20 characters. If the full value is needed, widen the target column instead.
INSERT INTO label_print (id, label) SELECT id, LEFT(name, 20) FROM products;
SELECT * FROM label_print ORDER BY id;Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
+----+----------------------+
| id | label |
+----+----------------------+
| 1 | USB cable |
| 2 | Wireless ergonomic k |
+----+----------------------+
2 rows in set (0.00 sec)04Content larger than a TEXT column (65,535 bytes)
TEXT looks unlimited, but it holds at most 65,535 bytes. Saving a 70,000-byte log or article body fails with Data too long for column 'body' at row 1.
Changing the column to MEDIUMTEXT lets the same INSERT store all 70,000 bytes (body_bytes 70000).
Setup
CREATE TABLE posts (id INT PRIMARY KEY, title VARCHAR(100), body TEXT);Query OK, 0 rows affected (0.01 sec)INSERT INTO posts VALUES (1, 'Long log', REPEAT('a', 70000));ERROR 1406 (22001): Data too long for column 'body' at row 1SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_OCTET_LENGTH FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'lab_a' AND TABLE_NAME = 'posts' AND COLUMN_NAME = 'body';
SELECT LENGTH(REPEAT('a', 70000)) AS new_bytes;+-------------+-----------+------------------------+
| COLUMN_NAME | DATA_TYPE | CHARACTER_OCTET_LENGTH |
+-------------+-----------+------------------------+
| body | text | 65535 |
+-------------+-----------+------------------------+
1 row in set (0.00 sec)
+-----------+
| new_bytes |
+-----------+
| 70000 |
+-----------+
1 row in set (0.00 sec)DATA_TYPE is text with CHARACTER_OCTET_LENGTH 65535, and the new value is 70000 bytes.
ALTER TABLE posts MODIFY body MEDIUMTEXT;Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0INSERT INTO posts VALUES (1, 'Long log', REPEAT('a', 70000));
SELECT id, title, LENGTH(body) AS body_bytes FROM posts;Query OK, 1 row affected (0.01 sec)
+----+----------+------------+
| id | title | body_bytes |
+----+----------+------------+
| 1 | Long log | 70000 |
+----+----------+------------+
1 row in set (0.00 sec)05A stored procedure variable shorter than the column it reads
The message says column 'v_name', but there is no such column: it is a variable declared in the procedure as VARCHAR(20). CALL get_customer_name(1) (Kim) works, and only customer 2, whose name is 34 characters, fails.
After recreating the procedure with VARCHAR(100), the same size as customers.name, the call for customer 2 returns the full name.
Setup
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(100));
INSERT INTO customers VALUES (1, 'Kim'), (2, 'International Trading Company Ltd.');
DELIMITER //
CREATE PROCEDURE get_customer_name(IN p_id INT)
BEGIN
DECLARE v_name VARCHAR(20);
SELECT name INTO v_name FROM customers WHERE id = p_id;
SELECT p_id AS id, v_name AS name;
END //
DELIMITER ;Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.01 sec)CALL get_customer_name(1);
CALL get_customer_name(2);+------+------+
| id | name |
+------+------+
| 1 | Kim |
+------+------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
ERROR 1406 (22001): Data too long for column 'v_name' at row 1SELECT id, name, CHAR_LENGTH(name) AS len FROM customers ORDER BY id;
SHOW CREATE PROCEDURE get_customer_name\G+----+------------------------------------+------+
| id | name | len |
+----+------------------------------------+------+
| 1 | Kim | 3 |
| 2 | International Trading Company Ltd. | 34 |
+----+------------------------------------+------+
2 rows in set (0.00 sec)
*************************** 1. row ***************************
Procedure: get_customer_name
sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
Create Procedure: CREATE DEFINER=`lab_a`@`%` PROCEDURE `get_customer_name`(IN p_id INT)
BEGIN
DECLARE v_name VARCHAR(20);
SELECT name INTO v_name FROM customers WHERE id = p_id;
SELECT p_id AS id, v_name AS name;
END
character_set_client: utf8mb4
collation_connection: utf8mb4_0900_ai_ci
Database Collation: utf8mb4_0900_ai_ci
1 row in set (0.00 sec)Customer 2's name is 34 characters, while SHOW CREATE PROCEDURE shows DECLARE v_name VARCHAR(20).
DROP PROCEDURE get_customer_name;
DELIMITER //
CREATE PROCEDURE get_customer_name(IN p_id INT)
BEGIN
DECLARE v_name VARCHAR(100);
SELECT name INTO v_name FROM customers WHERE id = p_id;
SELECT p_id AS id, v_name AS name;
END //
DELIMITER ;Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)CALL get_customer_name(2);+------+------------------------------------+
| id | name |
+------+------------------------------------+
| 2 | International Trading Company Ltd. |
+------+------------------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)FAQ
How do I fix Data too long for column in MySQL?
Make the column longer with ALTER TABLE ... MODIFY col VARCHAR(n), or cut the value yourself with LEFT(value, n) if losing the rest is fine.
What does at row 2 mean in ERROR 1406?
It is the row of the statement where the value was too long. In our UPDATE test, row 1 fit but was not changed either, because the whole statement failed.
Does VARCHAR(n) count bytes or characters?
Characters. The checks here use CHAR_LENGTH, which matches the limit in the error.
Is ERROR 1406 shown in Korean or Japanese?
In our test on MySQL 8.4 the message was English even with lc_messages set to ko_KR or ja_JP.
Why does a TEXT column give Data too long?
TEXT holds at most 65,535 bytes. Use MEDIUMTEXT for larger content such as long logs or article bodies.
ERROR 1406 names a column that does not exist in my table
It can be a variable in a stored procedure or function. Check its DECLARE ... VARCHAR(n) with SHOW CREATE PROCEDURE and make it as long as the source column.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13