Chinaunix首页 | 论坛 | 博客
  • 博客访问: 109293
  • 博文数量: 27
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 360
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-07 00:14
文章分类

全部博文(27)

文章存档

2015年(1)

2014年(20)

2013年(6)

我的朋友

分类: 系统运维

2014-11-11 23:39:23

在 /etc/my.cnf 的[mysql] 配置域下,添加如下一行:
default-character-set=utf8
那么执行在 mysql 中执行 show variables like "%character_set%" 会看到如下结果
character_set_connection=utf8 说明转送给mysqld的数据编码格式为utf8,
character_set_results 说明mysqld发送回来的数据是utf8格式。


load data local infile '/path' into table character set utf8;  把本地的/path 文件加载到数据库,并指明数据的编码格式为utf8。
如果不指定编码格式,那么就使用默认的编码格式latin1, 如果其中有中文,那么查询出来的数据会显示乱码,不管此时character_set_results 设置为任何值都不管用。


阅读(946) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~