MySQL error 1115 occurs when a query references a character set that your MySQL server does not recognize or support. This commonly happens with utf8mb4 on older versions, during database imports, or due to typos in charset names.
MySQL throws error 1115 (ER_UNKNOWN_CHARACTER_SET) when it cannot map the supplied character set name to any character set compiled into the server. This error prevents the execution of DDL (CREATE TABLE, ALTER TABLE) or DML statements that specify an unsupported charset. The error typically occurs in these scenarios: - Importing a database dump created on a newer MySQL version into an older one - Using a charset that was removed in a newer MySQL version (like ucs2 being removed in MySQL 8.0) - Specifying a charset that doesn't exist on the current server installation - Simple typos in the charset name (e.g., "utf-8mb4" instead of "utf8mb4")
First, verify which MySQL version you're running. Log in to MySQL and check:
SELECT VERSION();If you're running MySQL 5.5.2 or earlier and the error mentions utf8mb4, you need to upgrade to at least 5.5.3. For other unsupported charsets, check the MySQL documentation to determine the minimum version that supports it.
Run this command to see all character sets supported by your MySQL server:
SHOW CHARACTER SET;This displays the complete list of available charsets. Compare the charset from your error message with this list. If it's not present, the charset is not supported on your server version.
Review your SQL statements and configuration for common typos:
- Correct: utf8mb4 (no hyphens)
- Incorrect: utf-8mb4 or utf_8mb4
- Correct: utf8
- Incorrect: UTF-8 or utf-8
Character set names in MySQL are case-insensitive but must not contain hyphens. If you find typos, correct them in your SQL file, application config, or connection string.
If you're importing a dump file from a newer MySQL version, replace the unsupported charset before importing:
Using sed (Linux/macOS):
sed -i 's/CHARACTER SET utf8mb4/CHARACTER SET utf8/g' dump.sql
sed -i 's/utf8mb4/utf8/g' dump.sqlUsing find and replace (Windows):
Open the dump file in a text editor and use find/replace to change all instances of the charset.
Then import the modified file:
mysql -u root -p database_name < dump.sqlIf the charset should be supported on your version but isn't, upgrade MySQL to a newer version:
Ubuntu/Debian:
sudo apt-get update
sudo apt-get upgrade mysql-servermacOS (with Homebrew):
brew upgrade mysqlDocker:
Update your MySQL Docker image tag to a newer version in docker-compose.yml or your Dockerfile.
After upgrading, restart MySQL and re-run your import or SQL statements.
If you're connecting from an application, ensure the connection specifies a supported charset:
MySQL client:
mysql -u root -p --default-character-set=utf8 database_namePython:
import mysql.connector
conn = mysql.connector.connect(
host="localhost",
user="root",
password="password",
database="mydb",
charset="utf8"
)PHP (MySQLi):
$conn = new mysqli("localhost", "root", "password", "mydb");
$conn->set_charset("utf8mb4");Node.js:
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'mydb',
charset: 'utf8mb4'
});UTF8 vs UTF8MB4:
MySQL's native "utf8" charset uses a maximum of 3 bytes per character. To support all Unicode characters (including emoji), use utf8mb4, which uses up to 4 bytes per character. utf8mb4 is compatible with MySQL 5.5.3+. Never use utf8 for new databases if you need emoji or supplementary character support.
Charset Removal in MySQL 8.0:
MySQL 8.0 removed support for several obsolete charsets like ucs2 and utf16 if they were not compiled into the binary. If you're migrating from MySQL 5.7 to 8.0 and see error 1115, convert tables to utf8mb4 before upgrading.
Configuration File Settings:
If your my.cnf or my.ini contains invalid charset directives, MySQL won't start properly. Check these variables:
- character_set_server - Must be a valid charset
- character_set_database - Must be a valid charset
- collation_server - Must match the charset
Use SHOW VARIABLES to verify:
SHOW VARIABLES LIKE 'character_set%';
SHOW VARIABLES LIKE 'collation%';Collation Compatibility:
When changing charset, ensure the collation matches. For example, utf8mb4 only works with utf8mb4_* collations, not utf8_* collations.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions