在遇到了 ISO-8859-1 的许多问题并阅读了很多有关排序规则的内容之后,我终于明白我需要使用 charset UTF8 collate utf8_unicode_ci
。因此,我使用这些更改配置了整个应用程序,并且似乎工作顺利,直到我需要执行手动查询
SET @id := '10000016';
SET @invoice := (SELECT invoice FROM WAREHOUSE WHERE invoice_id = @id);
Run Code Online (Sandbox Code Playgroud)
此查询在 MySQL Workbench 中给我错误并带有排序规则消息:
Error Code: 1267. Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
Run Code Online (Sandbox Code Playgroud)
我可以使用 修复它SET @id := '10000016' collate utf8_unicode_ci;
,但这对我来说似乎很奇怪(至少可以说)。我确信缺少一些步骤。
也许我需要在 my.cnf 中调整一些东西?
SELECT @@character_set_client; # utf8
SELECT @@character_set_results; # utf8
SELECT @@collation_connection; # utf8_general_ci
Run Code Online (Sandbox Code Playgroud)
感谢您的时间