1
我試圖讓我的MySQL表從此MySQL Reference頁面表現爲實例2在UTF8表標榜不工作: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';
根據實例,這應該產生:
+------+
| c |
+------+
| Bar |
| Bär |
+------+
但我得到的只是簡單的"Bär"
。難道我做錯了什麼?我應該調整我的設置嗎?
我在Mac OS X上的MySQL 5.0.45上和Red Hat上的5.0.51a上試過這個。
編輯:我試過設置SET NAMES 'utf8'
,但這仍然給出了相同的結果。這樣做後我的變量是
+--------------------------+---------------------------------------------------------------------+
| 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/ |
+--------------------------+---------------------------------------------------------------------+