DBAtlas · Database operations atlas

1267: Illegal mix of collations

MySQL

What does it mean?

In a comparison or combining operation (JOIN, WHERE, UNION, CONCAT), two strings with different collations were combined and MySQL could not determine which collation rules to apply.

Why does it happen?

Usually comparing columns with different character sets/collations (e.g. utf8mb4_general_ci vs. utf8mb4_unicode_ci, or latin1 vs. utf8mb4), or a mismatch between a column and the connection collation. Common when tables/databases were created with different defaults.

How to fix it

Bring both sides of the comparison to the same collation: specify an explicit collation with COLLATE (e.g. col1 = col2 COLLATE utf8mb4_unicode_ci) or use CONVERT(... USING ...). For a permanent fix, convert the affected columns/tables to a single consistent character set and collation. Align the connection collation (collation_connection) as well.

Open in DBAtlas →

More from this engine