DBAtlas · Database operations atlas

1366: Incorrect string/integer value for column

MySQL

What does it mean?

A value incompatible with the column's type or character set was inserted into a column. Usually caused by a character encoding or type mismatch.

Why does it happen?

Writing a 4-byte emoji/character (utf8mb4) into a latin1 column, entering non-numeric text into a numeric column, a wrong connection charset, or sending a value of a different type than expected.

How to fix it

For character issues, convert the column/table to utf8mb4: ALTER TABLE my_table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci and set the connection charset to utf8mb4. Validate types in the application for numeric fields. Remember that the server runs in strict SQL mode (STRICT); the root cause is the type/encoding of the data.

Open in DBAtlas →

More from this engine