mysql 日文乱码_Mysql 导入日文数据乱码问题

做数据迁移后,通过ui发现有日文数据是乱码,通过ui直接修改日文则显示正常.

查了下资料,mysql字符集的作用如下:

MySQL字符集设置

• 系统变量:

–character_set_server:默认的内部操作字符集

– character_set_client:客户端来源数据使用的字符集

– character_set_connection:连接层字符集

– character_set_results:查询结果字符集

– character_set_database:当前选中数据库的默认字符集

– character_set_system:系统元数据(字段名等)字符集

– 还有以collation_开头的同上面对应的变量,用来描述字符序。

于是:

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)

而通过jdbc 的配置制定了连接字符集,所以通过ui设定日文无问题:

jdbc\:mysql\://10.1.0.198\:3306/mytestui?zeroDateTimeBehavior\=convertToNull&useUnicode\=true&characterEncoding\=utf-8

而导入数据时,由于没有明确指定连接字符集,mysql会使用默认的字符集进行导入操作,而默认字符集是latin1_swedish_ci:

mysql -h127.0.0.1 -umyaccount -p <.>

解决方案1:

修改系统的默认字符集为utf-8

解决方案2:

导入sql文件时,指定字符集:

mysql -h127.0.0. -umyaccount -p <.patch.sql>

Mysql explain:

Use charset_name as the default character set for the client and connection.

A common issue that can occur when the operating system uses utf8 or another

multi-byte character

set is that output from the mysql client is formatted incorrectly, due to

the fact that the MySQL client uses the latin1 character set by default. You

can usually fix such issues by using this option to force the client to use the

system character set instead

原文:http://www.cnblogs.com/dogharry/p/4614242.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值