Error 3142 appears when MySQL encounters malformed or unsupported content inside a JSON binary column or literal.
MySQL error 3142 ER_INVALID_JSON_BINARY_DATA means the JSON value being read or written is corrupted or contains unsupported types. Validate the JSON text or reserialize the data, then run the statement again to resolve the issue.
ER_INVALID_JSON_BINARY_DATA
MySQL throws error 3142 when it attempts to read or store a JSON value encoded in binary format and detects unexpected or unsupported bits. The server verifies every JSON document against its internal binary specification introduced in 5.7.8.
The error aborts the current statement because MySQL cannot safely interpret the malformed JSON. Fixing it is essential to prevent lost updates, wrong query results, or replication stops.
Corrupted JSON data imported from external systems frequently triggers 3142. Unsupported numerical formats, trailing bytes, or non-UTF8 characters also break MySQL's binary parser.
Application code that manually builds binary JSON without the MySQL JSON functions may produce invalid structures. Version mismatches between exporting and importing servers amplify the risk.
First localise the bad row with SELECT ... WHERE JSON_VALID(col) = 0. Update or delete any faulty documents. When inserting, wrap values in JSON_QUOTE or supply valid JSON text.
If the error appears during replication, skip the event, export the faulty row, repair the JSON offline, and re-insert a clean version.
INSERT statements that mix single quotes and unescaped double quotes often produce invalid JSON. Validate the literal with SELECT JSON_VALID('...').
LOAD DATA imports may pass a blob into a JSON column. Use SET @raw = CONVERT(col USING utf8mb4); SELECT JSON_VALID(@raw); to confirm integrity before insertion.
Always store JSON as text and let MySQL convert it. Rely on JSON_OBJECT, JSON_ARRAY, and JSON_SET instead of manual concatenation.
Add a CHECK constraint JSON_VALID(col) = 1 in MySQL 8.0 to block bad documents at write-time. Monitor the error log and replicate with --slave-skip-errors only for emergencies.
Error 3140 INVALID_ARGUMENT_FOR_JSON: occurs when function arguments are not valid JSON. Validate inputs before calling JSON functions.
Error 3141 INVALID_JSON_TEXT: raised when the text form of JSON is malformed. Use JSON_PRETTY to eyeball issues.
Missing commas, unmatched braces, or unescaped quotes create binary structures MySQL cannot parse.
Special IEEE NaN or Infinity values and non-UTF8 bytes violate MySQL's binary JSON specification.
Hardware faults, partial writes, or accidental overwrites damage existing JSON documents.
Dumping JSON from a newer MySQL release and loading into an older server introduces fields it cannot interpret.
Raised when a JSON function receives non-JSON input. Validate with JSON_VALID first.
Occurs when JSON text is syntactically wrong before binary conversion.
Triggered by non-UTF8 bytes inserted into JSON columns.
Run SELECT id FROM table WHERE JSON_VALID(json_col)=0 to list offending rows.
No. MySQL must reject invalid binary JSON for data integrity. Fix or drop the bad value instead.
Only if you validate and repair documents during export. Otherwise the same error reappears on import.
Galaxy's SQL editor highlights malformed JSON, auto-formats literals, and offers AI suggestions that generate valid JSON functions.