Common SQL Errors

MySQL Error 22: EE_UNKNOWN_CHARSET - How to Fix and Prevent

Galaxy Team
August 5, 2025

MySQL raises EE_UNKNOWN_CHARSET when it encounters a character set that is not compiled into the server or listed in its Index.xml definition files.

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 22 EE_UNKNOWN_CHARSET?

MySQL Error 22 EE_UNKNOWN_CHARSET appears when the server or client requests a character set that MySQL was not built with or cannot locate in its Index.xml. Use a supported character set, install the missing charset files, or recompile MySQL with the required charset to fix the problem.

Error Highlights

Typical Error Message

Character set '%s' is not a compiled character set and is not specified in the '%s' file

Error Type

Configuration Error

Language

MySQL

Symbol

EE_UNKNOWN_CHARSET

Error Code

22

SQL State

Explanation

Table of Contents

What is MySQL error 22 EE_UNKNOWN_CHARSET?

Error message: Character set '%s' is not a compiled character set and is not specified in the '%s' file.

MySQL throws EE_UNKNOWN_CHARSET when it cannot load or recognize the character set requested by a client, column definition, or server variable. The server checks compiled charsets and the Index.xml file in the charset directory.

If the requested charset is absent, error 22 is raised and the statement fails.

Resolving this error is critical because an unrecognized charset blocks client connections, schema changes, and data insertion that rely on the missing encoding. Production outages and data corruption risks can follow if the issue is ignored.

What Causes This Error?

Unsupported or misspelled character sets in CREATE DATABASE, CREATE TABLE, or SET NAMES statements trigger EE_UNKNOWN_CHARSET immediately.

MySQL validates the charset name against its compiled list and Index.xml.

Misconfigured my.cnf or my.ini files can set character_set_server or collation_server to a non-existent charset. The server fails to start or shows the error during runtime configuration reloads.

Custom MySQL builds compiled without optional charsets (e.g., utf8mb4_0900_ai_ci in older forks) produce the error when applications expect those encodings.

How to Fix MySQL Error 22 EE_UNKNOWN_CHARSET

First, confirm the typo or unsupported charset with SHOW CHARACTER SET.

If the charset is absent, switch to a supported one such as utf8mb4.

If the charset should exist, verify that the $MYSQL_HOME/share/charsets/Index.xml file lists it.

Corrupted or missing files can be restored by reinstalling the MySQL package.

For custom builds, recompile MySQL using -DWITH_EXTRA_CHARSETS=all or specify the exact charset in CMake to embed it in the binary.

Common Scenarios and Solutions

A startup failure due to character_set_server=utf16 in my.cnf is solved by replacing the value with utf8mb4 and restarting the service.

An application that issues SET NAMES latin10 can be fixed by changing the call to SET NAMES latin1 or another supported encoding.

Docker images trimmed for size may omit charset files.

Switching to the full community image or copying missing .xml and .conf charset files restores functionality.

Best Practices to Avoid This Error

Standardize on utf8mb4 for new schemas to leverage full Unicode and avoid obscure charsets.

Add automated integration tests that run SHOW CHARACTER SET LIKE 'utf8mb4' after container builds, preventing image promotion when charsets are missing.

Use Galaxy collections to store vetted CREATE statements so developers reuse approved character sets instead of ad-hoc names.

Related Errors and Solutions

Error 1115 unknown character set occurs on client side and is solved with the same charset verification steps.

Error 1267 illegal mix of collations appears when incompatible charsets mix in queries; fix by aligning column collations.

.

Common Causes

Related Errors

FAQs

Can I add a new charset without recompiling MySQL?

No. Charsets must be compiled into the server or listed in Index.xml. Recompilation or reinstalling a build with the charset is required.

Why does SHOW CHARACTER SET list fewer charsets in Docker?

Many lightweight images exclude optional charsets to reduce size. Use the full image or copy the missing charset files.

Does changing character_set_connection fix the error?

Only if the variable was set to the unsupported charset. Otherwise you must correct the server configuration or schema definition.

How does Galaxy help prevent EE_UNKNOWN_CHARSET?

Galaxy's AI copilot auto-suggests supported charsets and flags unknown ones during query drafting, lowering the risk of this error in production.

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