我在Mac上使用带有MySQL的velosurf,没有任何编码问题,但是当我切换到Linux机器时,我从velosurf获得的值编码不正确。
我发现它可能是默认连接字符集的问题。在Mac上我得到了:
mysql> show variables like "collation_%";
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)
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 | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.5.11-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)
在linux机器上,我有:
mysql> show variables like 'collation_%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
| collation_database | utf8_general_ci |
| collation_server | latin1_swedish_ci |
+----------------------+-------------------+
3 rows in set (0.00 sec)
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
创建数据库时设置数据库排序规则和字符集。我的问题是我无法更改客户端/连接/结果的默认字符集。
此外,启动连接时似乎没有任何方法可以使用velosurf设置charset。
有什么建议吗?
答案 0 :(得分:3)
MySQL有一个命令行标志来设置字符集。你可以试试吗? --default-字符集= UTF8
答案 1 :(得分:1)
我发现MySQL在以root用户身份连接时将始终使用默认字符集。但它适用于有限的用户(我应该从一开始就做的事情)。
这个“功能”似乎是特定于Linux的。至少在OS X中不会发生。