1273 – Unknown collation ‘utf8mb4_unicode_520_ci’
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
In MySQL, a collation is a set of rules for comparing characters in a character set. When creating tables or querying data in MySQL, developers may encounter the error #1273 – Unknown collation: 'utf8mb4_unicode_520_ci'. This error typically arises when using a specific collation that's not supported by the MySQL version in use. Understanding what causes this error and how to resolve it involves delving deeper into MySQL characters set and collations, as well as understanding version compatibility.
Understanding Collations and UTF8MB4
MySQL has different character sets and each character set has its own collations. A collation determines how string comparison is performed, which affects ordering (sorting) and equivalence (what counts as the same character).
UTF8MB4
The utf8mb4 charset is an extension of the utf8 charset in MySQL. It allows for the use of all Unicode characters, including emojis and other symbols that cannot be represented with the older utf8 charset (which actually only supports a subset of UTF-8).
Collation and Version-Specific Error
In MySQL 5.5 or earlier, the utf8mb4_unicode_520_ci collation is not available. This collation was introduced in MySQL 5.6, following the Unicode 5.2.0 standard. If you try to use it in an unsupported version, you receive the #1273 – Unknown collation: 'utf8mb4_unicode_520_ci' error.
The error indicates that MySQL does not recognize the collation name, likely because the server is using a version where this collation is not implemented.
Resolving the Error
Steps to Resolve
- Check MySQL Version: First, verify the version of MySQL running on your server. You can check this by executing:
Ensure your version is at least 5.6 or higher to use utf8mb4_unicode_520_ci.
- Upgrade MySQL: If your version is lower than 5.6, consider upgrading to a more recent version. Newer versions come with performance improvements, security updates, and support for a wider range of collations and features.
- Use Alternative Collation: If upgrading is not feasible, consider using a different collation that is supported in your version. For example,
utf8mb4_unicode_ciis a suitable alternative that is supported from MySQL 5.5 onwards. - Review Database Creation Scripts: Ensure any database creation or alter scripts do not specify unsupported collations. This includes examining SQL dumps and ORM configurations.
Example Correction
If the error arises while trying to create a table, like this:
You can modify it to:
This change ensures the collation is compatible with MySQL versions below 5.6.
Summary Table
| Key Aspect | Details |
| Error Code | #1273 |
| Error Message | Unknown collation: 'utf8mb4_unicode_520_ci' |
| Cause | Using a collation unavailable in the current MySQL version |
| Affected Versions | MySQL ≤ 5.5 |
| Solution 1 | Upgrade MySQL to version 5.6 or higher |
| Solution 2 | Use alternative collation (utf8mb4_unicode_ci) |
| Use Case Importance | Ensures compatibility and support for character operations |
Additional Considerations
Performance and Compatibility
While the utf8mb4_unicode_520_ci provides better support for recent Unicode standards, due to its stricter and more comprehensive sorting, it's important to consider your application's compatibility and performance requirements.
Impact on Databases Using Older MySQL Versions
Using utf8mb4_unicode_520_ci can cause issues when migrating databases from older MySQL versions to newer ones if the collation is not explicitly set or if defaults are assumed. Ensuring that your database scripts are forward-compatible can protect against such errors.
Configuration Management
For projects using configuration management or Infrastructure as Code (IaC) tools, ensure these configurations reflect the correct MySQL settings, including character sets and collations, to avoid runtime surprises.
By understanding the source of the collation error and applying these solutions, you can ensure that your MySQL databases operate smoothly and are compatible with international character representations across various MySQL versions.

