How to Fix MySQL Error 3144 (ER_INVALID_JSON_CHARSET)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mysql error 3144 when you pass a string with a bad character set into a JSON column. To fix it, convert the input string to UTF-8 before the database reads it. MySQL forces strict text rules on all JSON data types. The engine uses the symbol ER_INVALID_JSON_CHARSET and SQLSTATE 22032 for this failure. The error message states that it cannot create a JSON value from a string with the given character set. When your app or script sends binary or non-UTF-8 text into a JSON field, the query

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mysql error 3144 when you pass a string with a bad character set into a JSON column. To fix it, convert the input string to UTF-8 before the database reads it.

MySQL forces strict text rules on all JSON data types. The engine uses the symbol ER_INVALID_JSON_CHARSET and SQLSTATE 22032 for this failure. The error message states that it cannot create a JSON value from a string with the given character set. When your app or script sends binary or non-UTF-8 text into a JSON field, the query stops right away.

What causes mysql error 3144 in the database

MySQL stores JSON documents in an internal binary format that needs UTF-8 text. If a query sends a string marked as binary or Latin1, the parser rejects it. This often happens when you cast raw bytes or read from old tables.

Client session settings also trigger this error during normal writes. An app might open a database session with a legacy character set by mistake. Even if the text looks fine, the database checks the character set label on the string. If that label is not a valid UTF-8 type, the engine throws error 3144.

Stored routines and triggers can cause this issue as well. If you create a stored function while your session uses a binary character set, the routine keeps that setting. When the routine runs later and builds a JSON object, it fails with ER_INVALID_JSON_CHARSET.

File imports and bulk loads are another common source of trouble. When a team loads data from raw text files, the database might read the input bytes as binary strings. Passing those raw fields straight into a JSON column or function will break the import job.

How to find and fix the character set mismatch

Start by checking the character set of the columns and variables in your failing query. Look at the source tables to see if any text fields use binary blobs or old character sets. You can also check the session character set that your app uses when it logs in.

JSON Web Tokens (JWT) + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix the query right away, convert the string to UTF-8 inside the query before making the JSON value. This tells the database engine to change the character set label and check the bytes. Once the string uses UTF-8, the JSON parser accepts the value without trouble.

For a permanent fix, update the character set in your app connection pool settings. Make sure every worker and script starts its database session with full UTF-8 support. If an old table holds text in an older format, plan a safe schema change to update those columns.

How to prevent character set errors in production

Production fixes often go wrong when someone runs ad-hoc scripts from a local machine. A local tool might use the wrong character set and break triggers or views during a deploy. Keep your session rules consistent across every user and service to avoid this trap.

Teams should review schema updates and data fixes before they run on live databases. Setting up clear checks for database sessions helps catch bad client settings early. You can also mask sensitive fields like emails, phone numbers, card numbers, or national IDs in query results during checks.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

What does SQLSTATE 22032 mean in MySQL?

SQLSTATE 22032 is the standard error class for invalid JSON data. MySQL uses it for error 3144 when a string has a character set that JSON functions cannot use.

Why do binary columns trigger ER_INVALID_JSON_CHARSET?

Binary columns hold raw bytes with no text encoding rules. Because JSON requires valid UTF-8 characters, MySQL blocks raw binary strings unless you convert them to UTF-8 text first.

Can client session settings cause mysql error 3144?

Yes, if your client session uses a binary or legacy character set, string literals take on that setting. Sending those literals into a JSON column or function will trigger error 3144.

The query runs. The emails stay hidden.