MySQL 操作 '=' 的排序规则 (utf8mb4_unicode_ci,IMPLICIT) 和 (utf8mb4_general_ci,IMPLICIT) 的非法混合

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44027987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 22:20:32  来源:igfitidea点击:

Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

mysqlcollation

提问by Michael42

I got this error;

我收到了这个错误;

Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

操作 '=' 的排序规则 (utf8mb4_unicode_ci,IMPLICIT) 和 (utf8mb4_general_ci,IMPLICIT) 的非法混合

I changed "Collations" to "utf8mb4_unicode_ci". Then tables were truncated and I re-import rows again. But still getting same error

我将“排序规则”更改为“utf8mb4_unicode_ci”。然后表被截断,我再次重新导入行。但仍然得到同样的错误

回答by MrApnea

I am guessing you have different collations on the tables you are joining. It says you are using an illegal mix of collations in operations =.

我猜你在加入的表上有不同的排序规则。它表示您在操作中使用了非法的排序规则组合=

So you need to set collation. For example:

所以你需要设置排序规则。例如:

WHERE tableA.field COLLATE utf8mb4_general_ci = tableB.field

WHERE tableA.field COLLATE utf8mb4_general_ci = tableB.field

Then you have set the same collations on the =operation.

然后您在=操作上设置了相同的排序规则。

Since you have not provided more info about the tables this is the best pseudo code I can provide.

由于您尚未提供有关表格的更多信息,因此这是我可以提供的最佳伪代码。

回答by Prateek Bhuwania

For Join Query I used this piece of query to resolve such error:

对于 Join Query 我使用这个查询来解决这样的错误:

select * from contacts.employees INNER JOIN contacts.sme_info  
ON employees.login COLLATE utf8mb4_unicode_ci = sme_info.login

Earlier using the following query, I was getting the same error:

之前使用以下查询时,我遇到了同样的错误:

select * from contacts.employees LEFT OUTER JOIN contacts.sme_info  
ON employees.login = sme_info.login

Error: Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '='

I don't know much about collations but seems like both tables follow different rules for character set. Hence, the equal to operator was not able to perform. So in the first query I specified a collation set to collect and combine.

我不太了解排序规则,但似乎两个表都遵循不同的字符集规则。因此,等于运算符无法执行。所以在第一个查询中,我指定了一个整理集来收集和组合。

回答by TRANG Tú NH?

Check connection with charset=utf8mb4

检查与 charset=utf8mb4

'dsn'       => 'mysql:dbname=DatabaseName;host=localhost;charset=utf8mb4';

回答by jprog

Had the same problem and fixed it by updating the field's collation.

有同样的问题并通过更新字段的排序规则来修复它。

Even if you change the table's collation, the individual table fields still have the old collation. Try to alter the table and update those varchar fields

即使您更改表的排序规则,各个表字段仍具有旧的排序规则。尝试更改表并更新这些 varchar 字段

See example here

请参阅此处的示例