MySQL排序规则无法按文档中的说明进行工作 [英] MySQL collations not working as advertised in documentation
问题描述
我正试图从此 MySQL参考页:
CREATE TABLE germanutf8 (c CHAR(10)) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
INSERT INTO germanutf8 VALUES ('Bar'), ('Bär');
SELECT * FROM germanutf8 WHERE c = 'Bär';
根据示例,这应该产生:
According to the example, this should yield:
+------+
| c |
+------+
| Bar |
| Bär |
+------+
但是我所得到的很简单贝尔
。难道我做错了什么?我应该调整设置吗?
But all I'm getting is simple "Bär"
. Am I doing something wrong? Should I adjust my settings?
我已经在Mac OS X的MySQL 5.0.45和Red Hat的5.0.51a上进行了尝试。
I've tried this on MySQL 5.0.45 on Mac OS X and on 5.0.51a on Red Hat.
编辑:我曾尝试设置 SET NAMES‘utf8'
,但这仍然会产生相同的结果。这样做之后,我的变量是
I have tried setting SET NAMES 'utf8'
, but this still gives the same result. After doing so my variables are
+--------------------------+---------------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.0.45-osx10.4-powerpc-64bit/share/mysql/charsets/ |
+--------------------------+---------------------------------------------------------------------+
推荐答案
在插入时是否收到任何警告?
Did you get any warnings on your INSERT?
您确定您的MySQL客户端能够正确解释您键入的内容吗?例如。如果您要通过SSH进入服务器并从命令行运行mysql,则shell编码和mysql客户端编码是否都设置为UTF-8?
Are you sure your MySQL-client interprets what you type correctly? E.g. if you are SSHing into a server, and running mysql from the command line, is both the shell encoding and the mysql client encoding set to UTF-8?
您是否尝试过运行
SET NAMES 'utf8'
在运行这些查询之前?
这篇关于MySQL排序规则无法按文档中的说明进行工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!