Unknown character set
Production Risk
Low — DDL fails; no data loss.
ER_UNKNOWN_CHARACTER_SET (1115, SQLSTATE 42000) is raised when a CHARACTER SET name specified in a CREATE TABLE, ALTER TABLE, or SET NAMES statement does not exist in the MySQL server's compiled-in character set list.
- 1Typo in the character set name (e.g., "utf-8" instead of "utf8")
- 2Using a character set name from a different database system (e.g., PostgreSQL's "UTF8" syntax)
- 3The MySQL build does not include the requested character set
CREATE TABLE t (name VARCHAR(50) CHARACTER SET utf-8);
expected output
ERROR 1115 (42000): Unknown character set: 'utf-8'
Fix
Use the correct MySQL character set name
WHEN Always — MySQL uses "utf8mb4" for full Unicode support.
-- List available character sets: SHOW CHARACTER SET; -- Use the correct name: CREATE TABLE t (name VARCHAR(50) CHARACTER SET utf8mb4);
Why this works
MySQL character set names use underscores, not hyphens; "utf8mb4" is the correct name for 4-byte UTF-8.
✕ Use "utf8" instead of "utf8mb4" for new tables
MySQL's "utf8" is actually utf8mb3 (3-byte only) and cannot store 4-byte characters like emoji; always use "utf8mb4".
MySQL 8.0 — 1115 ER_UNKNOWN_CHARACTER_SET
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev