12
返回列表 发新帖
楼主: 冷月汉宫秋

[原创] character_set_client等的字符集设置

[复制链接]
论坛徽章:
1
ITPUB 11周年纪念徽章
日期:2012-10-09 18:16:00
11#
发表于 2013-8-5 10:04 | 只看该作者
@冷月汉宫秋
mysql命令登录机的/etc/my.cnf中[mysql]下配置。

使用道具 举报

回复
论坛徽章:
14
2009新春纪念徽章
日期:2009-01-04 14:52:28沸羊羊
日期:2015-03-04 14:51:52优秀写手
日期:2014-03-14 06:00:13马上有房
日期:2014-02-18 16:42:022014年新春福章
日期:2014-02-18 16:42:022013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:08:15蜘蛛蛋
日期:2012-06-27 21:08:142012新春纪念徽章
日期:2012-01-04 11:53:29ITPUB十周年纪念徽章
日期:2011-11-01 16:23:26
12#
发表于 2013-8-9 14:36 | 只看该作者
冷月汉宫秋 发表于 2013-8-1 16:44
额。。那个2)我看到了,可是我在[client]里已经加了default-character-set=utf8后,用root登录进去,是不 ...

这是我们的:/etc/my.cnf:
[mysqld]
ndbcluster
datadir=/home/mysqlc/my_cluster/mysqld_data
basedir=/home/mysqlc/mysqlc
character_set_server=gbk
port=5000

[client]
default-character-set = gbk

[mysql]
default-character-set = gbk

使用道具 举报

回复
论坛徽章:
4
奔驰
日期:2013-08-01 10:31:12ITPUB社区12周年站庆徽章
日期:2013-08-13 16:52:38奥迪
日期:2013-09-12 10:42:18奔驰
日期:2013-12-27 20:52:52
13#
 楼主| 发表于 2013-8-12 11:00 | 只看该作者
yulihua49 发表于 2013-8-9 14:36
这是我们的:/etc/my.cnf:
[mysqld]
ndbcluster

好的,谢谢各位啦~~我已经找到解决方法了,非常感谢各位的帮忙!

使用道具 举报

回复
论坛徽章:
52
2015年新春福章
日期:2015-03-06 11:57:312012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:25生肖徽章2007版:龙
日期:2012-02-07 10:33:22生肖徽章2007版:龙
日期:2012-02-07 10:33:22生肖徽章2007版:龙
日期:2012-02-07 10:33:22生肖徽章2007版:龙
日期:2012-02-07 10:33:22生肖徽章2007版:龙
日期:2012-02-07 10:33:22生肖徽章2007版:龙
日期:2012-02-07 10:32:552012新春纪念徽章
日期:2012-02-07 09:59:35
14#
发表于 2013-8-14 13:07 | 只看该作者
本帖最后由 jinguanding 于 2013-8-14 13:14 编辑
冷月汉宫秋 发表于 2013-8-1 16:44
额。。那个2)我看到了,可是我在[client]里已经加了default-character-set=utf8后,用root登录进去,是不 ...

问题:不允许重新启动的生产环境出现字符集设置不对,如何从默认的latin1修改为utf8

生产环境正确做法和步骤:

1.在配置文件my.cnf中 [client] 增加 default-character-set =utf8 ,会立即对本机上的新创建连接生效

2.在配置文件my.cnf中 [mysqld] 增加 default-character-set =utf8 ,待mysqld服务重新启动后生效

3. 执行SET语句修改字符集,对非本机新创建的连接也会生效

SET GLOBAL character_set_clinet=utf8;
SET GLOBAL character_set_connection=utf8;
SET GLOBAL character_set_database=utf8;
SET GLOBAL character_set_results=utf8;
SET GLOBAL character_set_server=utf8;

4.对于之前的连接线程,则没有办法,除非他们自己设置为utf8 或者等待其断开重新连接


www.hotpu.cn




使用道具 举报

回复
论坛徽章:
32
ITPUB十周年纪念徽章
日期:2011-11-01 16:25:22马上加薪
日期:2014-12-08 22:53:43马上有房
日期:2014-12-09 01:05:19美羊羊
日期:2015-03-04 14:52:282015年新春福章
日期:2015-03-06 11:58:18巨蟹座
日期:2015-11-17 11:02:55双子座
日期:2015-11-17 12:21:47白羊座
日期:2015-12-10 17:27:08狮子座
日期:2016-02-23 10:11:01双子座
日期:2016-02-23 10:17:05
15#
发表于 2013-10-16 14:24 | 只看该作者
1、修改配置文件:default-character-set=utf8;
2、set global character -set-connctions=utf8;
     set global character-set -server=utf8;
     set global character- set-client=utf8;
     set global character-set-database=utf8;
   

使用道具 举报

回复
论坛徽章:
0
16#
发表于 2014-3-6 09:32 | 只看该作者
jinguanding 发表于 2013-8-14 13:07
问题:不允许重新启动的生产环境出现字符集设置不对,如何从默认的latin1修改为utf8

生产环境正确做法 ...

这个是对于默认的latin1到utf8 有效。 如果客户那边显式设置gbk,应该可以把server端设置的给修改掉吧。求问

使用道具 举报

回复
论坛徽章:
0
17#
发表于 2014-3-6 23:37 | 只看该作者
jinguanding 发表于 2013-8-14 13:07
问题:不允许重新启动的生产环境出现字符集设置不对,如何从默认的latin1修改为utf8

生产环境正确做法 ...

Hi,
    我查了下如果client那边没有显示指定的话,还会是默认的,比如latin1。 具体描述可以看下面

http://bugs.mysql.com/bug.php?id=35372


Updated the description for character_set_client:

The character set for statements that arrive from the client. The
session value of this variable is set using the character set
requested by the client when the client connects to the server. (Many
clients support a --default-character-set option to enable this
character set to be specified explicitly.) The global
value of the variable is used to set the session value in cases when
the client-requested value is unknown or not available, or the server
is configured to ignore client requests:

* The client is from a version of MySQL older than MySQL 4.1, and thus
does not request a character set.

* The client requests a character set not known to the server. For
example, a Japanese-enabled client requests sjis when connecting to a
server not configured with sjis support.

* mysqld was started with the --skip-character-set-client-handshake
option, which causes it to ignore client character set configuration.
This reproduces MySQL 4.0 behavior and is useful should you wish to
upgrade the server without upgrading all the clients.

所以光是从server这边去设置是没有效果的。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表