Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4
Comparing two strings needs one collation. When both sides are columns (or a procedure parameter) with different collations, the message shows both as IMPLICIT, MySQL cannot decide which to use, and the comparison stops with ERROR 1267.
The usual pair on MySQL 8.x is utf8mb4_0900_ai_ci (the 8.0+ default) against utf8mb4_general_ci or utf8mb4_unicode_ci from older tables. Check the actual collations in information_schema.columns or information_schema.tables. Below are three cases reproduced on MySQL 8.4.
01JOIN columns with different collations
customers.code is utf8mb4_0900_ai_ci and legacy_orders.cust_code is utf8mb4_general_ci. JOIN … ON o.cust_code = c.code fails with Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='.
information_schema.columns showed the two collations. After ALTER TABLE legacy_orders CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci, the same JOIN returned 2 rows.
Setup
CREATE TABLE customers (code VARCHAR(10) COLLATE utf8mb4_0900_ai_ci PRIMARY KEY, name VARCHAR(20));
CREATE TABLE legacy_orders (id INT PRIMARY KEY, cust_code VARCHAR(10) COLLATE utf8mb4_general_ci);
INSERT INTO customers VALUES ('C01', 'Kim'), ('C02', 'Lee');
INSERT INTO legacy_orders VALUES (1, 'C01'), (2, 'C02');Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0SELECT o.id, c.name FROM legacy_orders o JOIN customers c ON o.cust_code = c.code;ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='SELECT table_name, column_name, collation_name FROM information_schema.columns WHERE table_schema = 'lab_a' AND column_name IN ('code', 'cust_code');+---------------+-------------+--------------------+
| TABLE_NAME | COLUMN_NAME | COLLATION_NAME |
+---------------+-------------+--------------------+
| customers | code | utf8mb4_0900_ai_ci |
| legacy_orders | cust_code | utf8mb4_general_ci |
+---------------+-------------+--------------------+
2 rows in set (0.00 sec)ALTER TABLE legacy_orders CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0CONVERT TO changes every string column of the table. On a large table it rewrites the table, so plan the time.
SELECT o.id, c.name FROM legacy_orders o JOIN customers c ON o.cust_code = c.code;+----+------+
| id | name |
+----+------+
| 1 | Kim |
| 2 | Lee |
+----+------+
2 rows in set (0.00 sec)02Joining a table in another database with a different default collation
The erp database was created with utf8mb4_unicode_ci, so erp.items uses it. lab_a.stock was created without a collation and got utf8mb4_0900_ai_ci. Joining them on item_code fails with ERROR 1267.
information_schema.tables showed items = utf8mb4_unicode_ci and stock = utf8mb4_0900_ai_ci. Without changing either table, putting COLLATE utf8mb4_unicode_ci on one side, ON i.item_code = s.item_code COLLATE utf8mb4_unicode_ci, made the query return 2 rows.
Setup
CREATE DATABASE erp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE erp.items (item_code VARCHAR(10) PRIMARY KEY, item_name VARCHAR(20));
INSERT INTO erp.items VALUES ('I01', 'Bolt'), ('I02', 'Nut');
GRANT SELECT ON erp.* TO lab_a;Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 0 rows affected (0.00 sec)CREATE TABLE stock (item_code VARCHAR(10) PRIMARY KEY, qty INT);
INSERT INTO stock VALUES ('I01', 50), ('I02', 30);Query OK, 0 rows affected (0.02 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0SELECT s.item_code, i.item_name, s.qty FROM stock s JOIN erp.items i ON i.item_code = s.item_code;ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='SELECT table_schema, table_name, table_collation FROM information_schema.tables WHERE table_name IN ('stock', 'items');+--------------+------------+--------------------+
| TABLE_SCHEMA | TABLE_NAME | TABLE_COLLATION |
+--------------+------------+--------------------+
| erp | items | utf8mb4_unicode_ci |
| lab_a | stock | utf8mb4_0900_ai_ci |
+--------------+------------+--------------------+
2 rows in set (0.00 sec)COLLATE in the query is handy when you cannot alter the other system's tables.
SELECT s.item_code, i.item_name, s.qty FROM stock s JOIN erp.items i ON i.item_code = s.item_code COLLATE utf8mb4_unicode_ci;+-----------+-----------+------+
| item_code | item_name | qty |
+-----------+-----------+------+
| I01 | Bolt | 50 |
| I02 | Nut | 30 |
+-----------+-----------+------+
2 rows in set (0.00 sec)03Procedure parameter declared with a different collation than the column
find_member(IN p_id VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci) compares p_id with members.login_id, which is utf8mb4_unicode_ci. CALL find_member('kim01') fails with ERROR 1267. The parameter also counts as IMPLICIT, just like a column.
After recreating the procedure with the parameter as COLLATE utf8mb4_unicode_ci, the same CALL returned Kim.
Setup
CREATE TABLE members (login_id VARCHAR(20) COLLATE utf8mb4_unicode_ci PRIMARY KEY, name VARCHAR(20));
INSERT INTO members VALUES ('kim01', 'Kim');
CREATE PROCEDURE find_member(IN p_id VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci)
SELECT name FROM members WHERE login_id = p_id;Query OK, 0 rows affected (0.02 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)CALL find_member('kim01');ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='SELECT column_name, collation_name FROM information_schema.columns WHERE table_schema = 'lab_a' AND table_name = 'members';+-------------+--------------------+
| COLUMN_NAME | COLLATION_NAME |
+-------------+--------------------+
| login_id | utf8mb4_unicode_ci |
| name | utf8mb4_0900_ai_ci |
+-------------+--------------------+
2 rows in set (0.00 sec)DROP PROCEDURE find_member;
CREATE PROCEDURE find_member(IN p_id VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci)
SELECT name FROM members WHERE login_id = p_id;Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)CALL find_member('kim01');+------+
| name |
+------+
| Kim |
+------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)FAQ
What does Illegal mix of collations IMPLICIT mean?
IMPLICIT means the value comes from a column (or a routine parameter). When both sides are IMPLICIT with different collations, MySQL has no rule to pick one and raises 1267.
How do I check the collation of a column in MySQL?
SELECT table_name, column_name, collation_name FROM information_schema.columns WHERE table_schema = '<db>'; shows it per column. information_schema.tables shows the table default.
How do I fix 1267 without altering the table?
Add COLLATE <collation> to one side of the comparison, for example ON a.col = b.col COLLATE utf8mb4_unicode_ci.
utf8mb4_0900_ai_ci vs utf8mb4_general_ci — why do they clash?
Both are utf8mb4 but different collations. Tables created on MySQL 8.x get utf8mb4_0900_ai_ci by default, so joining them to older general_ci or unicode_ci tables raises 1267.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13