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.
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.
First, verify which MySQL version you're running:
mysql --versionAlso check the version of the server you're importing to:
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.
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):
SEARCH FOR: utf8mb4_0900_ai_ci
SEARCH FOR: utf8mb4_unicode_520_ciUse the sed command to replace all instances of the unsupported collation:
# 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.sqlNote: On macOS, use sed -i '' instead of sed -i:
sed -i '' 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' dump.sqlIf 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.
Now import your modified dump file:
mysql -u username -p database_name < dump.sqlOr via MySQL client:
SOURCE /path/to/dump.sql;If the import succeeds, the error is resolved.
After successful import, verify the collation was applied correctly:
-- 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.
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.
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