MySQL连接字符集问题 [英] MySQL connection character set problems

查看:98
本文介绍了MySQL连接字符集问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上使用带有MySQL的velosurf,没有任何编码问题,但是当我切换到Linux机器,我从velosurf获得的值不能正确编码。

I'm using velosurf with MySQL on a Mac, without any encoding problems, but when I switch to a Linux machine, the values I get from velosurf are not encoded correctly.

我发现它可能是一个与默认连接字符集的问题。在Mac上我有:

I found out it might be a problem with the default connection character set. On the Mac I got:

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机器上,我有:

While on the linux machine, I have:

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)

数据库排序规则和字符集在创建数据库时设置。我的问题是,我不能更改客户端/连接/结果的默认字符集。

The database collation and character set are set when I create the database. My problem is that I can't change the default character sets for the client/connection/results.

此外,似乎没有任何方式设置

Also, there doesn't seem to be any way to set the charset with velosurf when the connection is initiated.

任何建议?

推荐答案

p>我发现MySQL连接时将始终使用默认字符集作为root。但它对有限的用户(我从一开始就应该做的事情)工作。

I found out that MySQL will always use the default character set when connecting as root. But it works OK for limited users (something I should have been doing from the beginning).

这个功能似乎是Linux特定的。至少它不会在OS X中发生。

This "feature" seems to be Linux specific. At least it doesn't happen in OS X.

这篇关于MySQL连接字符集问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆