Common SQL Errors

MySQL Error 1366 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD - How to Fix and Prevent

Galaxy Team
August 6, 2025

<p>MySQL throws ER_TRUNCATED_WRONG_VALUE_FOR_FIELD (1366) when a supplied value cannot be stored in the target column because of an invalid data type or format.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1366?

<p>MySQL Error 1366: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD arises when a value does not fit the column data type or format. Fix it by validating input, casting data, or altering the column to match the incoming value.</p>

Error Highlights

Typical Error Message

Incorrect %s value: '%s' for column '%s' at row %ld

Error Type

Data Conversion Error

Language

MySQL

Symbol

ER_TRUNCATED_WRONG_VALUE_FOR_FIELD

Error Code

1366

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 1366 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD?

Error 1366 appears when MySQL receives a value that cannot be stored in a column because its type or format is incompatible. The server rejects or truncates the value and raises the error in strict SQL mode.

The message looks like: Incorrect %s value: '%s' for column '%s' at row %ld. It pinpoints the bad value, column, and row, helping you locate the problem quickly.

What Causes This Error?

The error is triggered by data type mismatches, invalid date or time strings, out-of-range numbers, or incorrect character encodings. Strict SQL mode turns what could be a warning into a full error.

User input, ETL jobs, or application code that bypasses validation frequently introduce malformed data. Bulk loads from CSV files are another common culprit.

How to Fix MySQL Error 1366

Identify the failing row with SELECT or by rerunning the INSERT with LIMIT. Validate and sanitize each value in application code before sending it to MySQL. Use CAST or CONVERT to coerce input when appropriate.

Alternatively, adjust the target column with ALTER TABLE to accommodate the incoming data type or size. For immediate relief, you can relax sql_mode, but that should be temporary.

Common Scenarios and Solutions

Invalid date like '2024-02-30' in a DATE column causes the error; fix by correcting the date string. Oversized varchar values need column length expansion or truncation logic.

Decimal overflow happens when a number exceeds the defined precision. Increase the precision or round the number before insertion.

Best Practices to Avoid This Error

Keep strict SQL mode on in production to surface problems early. Validate all user input at the application layer and use prepared statements. Monitor ingestion pipelines for truncation warnings.

Adopt Galaxy’s AI copilot to preview query results and detect problematic rows before commits, reducing runtime surprises.

Related Errors and Solutions

Error 1292 (Truncated incorrect datetime value) appears for invalid datetime strings and is fixed in a similar way: validate and convert input before insertion. Error 1406 (Data too long for column) surfaces when varchar or text data exceeds column size; increase column length or trim data.

Common Causes

Data Type Mismatch

Inserting strings into numeric columns or vice versa triggers the error because MySQL cannot coerce the value under strict mode.

Invalid Date or Time

Date strings with impossible calendar values or wrong formats cause the server to reject the row.

Numeric Overflow

Numbers exceeding DECIMAL or INTEGER precision throw error 1366 when strict mode is active.

Wrong Character Encoding

Supplying UTF-8 bytes to a latin1 column produces invalid byte sequences that MySQL refuses to store.

Related Errors

Error 1292 - Truncated incorrect datetime value

Occurs when a datetime string is invalid. Fix by validating dates or adjusting column type.

Error 1406 - Data too long for column

Raised when varchar or text input exceeds column length. Resolve by enlarging the column or trimming data.

Error 1264 - Out of range value for column

Appears when numeric input exceeds column range. Increase precision or clamp the value.

FAQs

Is disabling STRICT mode safe?

It prevents the error but may silently corrupt data. Enable it only during controlled bulk loads.

Why does the error mention row 0?

MySQL reports row 0 when the failure occurs before any data is inserted, often in multi-row statements.

Can Galaxy help avoid this error?

Galaxy validates data types, previews result sets, and flags potential mismatches before you run INSERT or UPDATE.

Does charset affect error 1366?

Yes. Inserting UTF-8 bytes into latin1 columns can trigger the error due to invalid encoding.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo