更新: 事实证明,这与数据库服务器本身没有直接关系,而是客户端编码。如果客户端使用编码utf8,则会错误地呈现德语字符。但如果客户端使用编码cp850,则正确呈现德语字符。但我需要使用utf8,因为应用程序可能需要处理其他类别的字符。我该怎么办?
原件:
我有两个数据库服务器,从同一个mysql客户端查看,server1正确呈现德语字符,而server2则没有。以下是差异。但是我很困惑,因为server2更多地使用了utf8。可能是什么原因造成的? server1的编码:
mysql> SHOW VARIABLES LIKE "character\_set\_database"; +------------------------+--------+ | Variable_name | Value | +------------------------+--------+ | character_set_database | latin1 | +------------------------+--------+ 1 row in set (0.00 sec) mysql> SHOW VARIABLES LIKE 'character\_set\_%'; +--------------------------+--------+ | Variable_name | Value | +--------------------------+--------+ | character_set_client | cp850 | | character_set_connection | cp850 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | cp850 | | character_set_server | latin1 | | character_set_system | utf8 | +--------------------------+--------+
mysql> SHOW VARIABLES LIKE 'character\_set\_%'; +--------------------------+--------+ | 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 | utf8 | | character_set_system | utf8 | +--------------------------+--------+ 7 rows in set (0.01 sec) mysql> SHOW VARIABLES LIKE "character\_set\_database"; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | character_set_database | utf8 | +------------------------+-------+ 1 row in set (0.00 sec)