mysql默认为utf-8,但是CMD却不能插入中文

mysql数据库安装的时候选择了utf8的编码,但是在cmd界面插入中文数据时,总是出现ERROR:1366(HY000)Incorrect string value 这样的错误 。

----------------------------------------------------------------------------------------------

 

我google了很久,试了很多种方法都没用,只有一个地方说的方法有效。就是将MySQL Server 5.2中的my.ini中的CLIENT SECTION部分中的default-character-set=utf-8改为default-character-set=GBK,其他的都不变,然后重新打开mysql的cmd界面执行插入操作就ok了。

 

没改之前的my.ini为:

 

# MySQL Server Instance Configuration File

# ----------------------------------------------------------------------

 

... ...

 

# CLIENT SECTION

# ----------------------------------------------------------------------

#

# The following options will be read by MySQL client applications.

# Note that only client applications shipped by MySQL are guaranteed

# to read this section. If you want your own MySQL client program to

# honor these values, you need to specify it as an option during the

# MySQL client library initialization.

#

[client]

 

port=3306

 

[mysql]

 

default-character-set=utf8

# SERVER SECTION

# ----------------------------------------------------------------------

 

... ...

 

 

改了之后为:

 

# MySQL Server Instance Configuration File

# ----------------------------------------------------------------------

 

... ...

# CLIENT SECTION

# ----------------------------------------------------------------------

#

# The following options will be read by MySQL client applications.

# Note that only client applications shipped by MySQL are guaranteed

# to read this section. If you want your own MySQL client program to

# honor these values, you need to specify it as an option during the

# MySQL client library initialization.

#

[client]

 

port=3306

 

[mysql]

 

default-character-set=GBK

 

# SERVER SECTION

# ----------------------------------------------------------------------

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值