How to fix ERROR 1273: Unknown collation in MySQL

MySQLINTERMEDIATEMEDIUMUpdated Dec 25, 2025· 285 views

Error 1273 occurs when your MySQL server doesn't recognize a collation used in your database dump, typically because the dump was created with a newer MySQL version than your target server. You can resolve this by replacing the unsupported collation with a compatible one or upgrading MySQL.

Quick fix

Fixes ERROR 1273: Unknown collation

mysql --version
  1. Check your MySQL version
  2. Identify the unsupported collation in your SQL dump
  3. Replace unsupported collation (Linux/macOS)
  4. Replace unsupported collation (Windows/GUI)
mysql — error
mysql --version
ERROR 1273: Unknown collation

What this error means

Error 1273 happens when MySQL encounters a character set collation it doesn't support. Collations define how characters are sorted and compared in your database. When you import a database dump created in a newer MySQL version (like 8.0+) into an older MySQL version or MariaDB, the server encounters collations it was never designed to understand—such as utf8mb4_0900_ai_ci (introduced in MySQL 8.0.1). The error prevents the import from completing because the database schema references collations that don't exist in your current MySQL installation. This typically occurs during database migrations, when moving applications between servers, or when working with Docker containers that run different MySQL versions than your development environment.

Typical symptoms

  • Import fails with "ERROR 1273 (HY000): Unknown collation" when running mysqldump restore
  • Application startup fails when trying to initialize the database
  • phpmyadmin or other GUI tools fail to import SQL dump files
  • Error message specifies an unknown collation like "utf8mb4_0900_ai_ci" or "utf8mb4_unicode_520_ci"
  • Database migration or setup scripts halt during execution

Common causes

  1. Database dump was created with MySQL 8.0+ but is being imported into an older MySQL version or MariaDB
  2. Development environment uses a different MySQL version than the target deployment server
  3. Docker container running an older MySQL version trying to import a newer database schema
  4. Mismatched MySQL versions between local machine (XAMPP/WAMP with MariaDB) and remote server
  5. Migration script includes unsupported collation specifications for the target server

How to fix "ERROR 1273: Unknown collation"

1Check your MySQL version

First, verify which MySQL version you're running:

bash
mysql --version

Also check the version of the server you're importing to:

sql
SELECT VERSION();

If the source version (where the dump was created) is newer than the target version, you'll need to replace the unsupported collations.

2Identify the unsupported collation in your SQL dump

Open your SQL dump file and search for collation declarations. Common unsupported collations are:

- utf8mb4_0900_ai_ci (MySQL 8.0.1+)
- utf8mb4_unicode_520_ci (MySQL 5.6+, not in 5.5)

You can search in your text editor using find (Ctrl+F or Cmd+F):

bash
SEARCH FOR: utf8mb4_0900_ai_ci
SEARCH FOR: utf8mb4_unicode_520_ci
3Replace unsupported collation (Linux/macOS)

Use the sed command to replace all instances of the unsupported collation:

bash
# Replace utf8mb4_0900_ai_ci with utf8mb4_unicode_ci
sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' dump.sql

# Or replace utf8mb4_unicode_520_ci with utf8mb4_unicode_ci
sed -i 's/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g' dump.sql

Note: On macOS, use sed -i '' instead of sed -i:

bash
sed -i '' 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' dump.sql
4Replace unsupported collation (Windows/GUI)

If you're on Windows or prefer a graphical editor:

1. Open your SQL dump file in a text editor (Notepad++, VS Code, etc.)
2. Use Find and Replace (Ctrl+H or Cmd+H)
3. Find: utf8mb4_0900_ai_ci
4. Replace with: utf8mb4_unicode_ci
5. Click "Replace All"
6. Save the file

Alternatively, if replacing with utf8mb4_unicode_ci causes issues, try utf8mb4_general_ci for maximum compatibility.

5Import the modified SQL dump

Now import your modified dump file:

bash
mysql -u username -p database_name < dump.sql

Or via MySQL client:

sql
SOURCE /path/to/dump.sql;

If the import succeeds, the error is resolved.

6Verify collation in imported database

After successful import, verify the collation was applied correctly:

sql
-- Check database collation
SHOW CREATE DATABASE database_name;

-- Check table collation
SHOW CREATE TABLE table_name;

-- Check column collation
SHOW FULL COLUMNS FROM table_name;

All should show utf8mb4_unicode_ci or your replacement collation.

Advanced notes

Character Set Considerations: When replacing utf8mb4_0900_ai_ci with utf8mb4_unicode_ci, you're maintaining utf8mb4 character support (which includes emojis and all Unicode characters). If you replace with utf8 or utf8_general_ci instead, you risk data loss if your database contains characters outside the Basic Multilingual Plane (BMP) such as emojis, rare symbols, or certain Asian characters. utf8mb4 is always preferred over utf8 in modern MySQL.

Long-term Solution: Rather than repeatedly replacing collations during migrations, consider upgrading your MySQL server to version 8.0+ or ensuring all environments run compatible versions. If upgrading isn't possible, use mysqldump --default-character-set=utf8mb4 --set-gtid-purged=OFF when creating exports to generate dumps compatible with older servers.

Docker Optimization: If using Docker, ensure your image tags match across environments. For example, if using mysql:8.0, all servers should use 8.0. If mixing versions is unavoidable, explicitly export with compatibility flags to prevent collation mismatches.

Frequently asked questions

What does "ERROR 1273: Unknown collation" mean?
Error 1273 happens when MySQL encounters a character set collation it doesn't support. Collations define how characters are sorted and compared in your database. 1).
How do I fix "ERROR 1273: Unknown collation"?
Error 1273 occurs when your MySQL server doesn't recognize a collation used in your database dump, typically because the dump was created with a newer MySQL version than your target server. You can resolve this by replacing the unsupported collation with a compatible one or upgrading MySQL.
What causes "ERROR 1273: Unknown collation"?
Database dump was created with MySQL 8.0+ but is being imported into an older MySQL version or MariaDB Development environment uses a different MySQL version than the target deployment server Docker container running an older MySQL version trying to import a newer database schema
Is the "ERROR 1273: Unknown collation" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading