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
# ----------------------------------------------------------------------
--转自