首页 > 代码库 > mysql添加中文,Data too long for column错误

mysql添加中文,Data too long for column错误

最开始以为是自己字符长度问题,缩短后还是有问题。原来是因为中文编码。

解决办法:修改my.ini文件中的default_character_set=gbk;

# 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# ----------------------------------------------------------------------## The following options will be read by the MySQL Server. Make sure that# you have installed the server correctly (see above) so it reads this # file.#[mysqld]# The TCP/IP Port the MySQL Server will listen onport=3306#Path to installation directory. All paths are usually resolved relative to this.basedir="C:/Program Files/MySQL/MySQL Server 5.0/"#Path to the database rootdatadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/"# The default character set that will be used when a new schema or table is# created and no character set is defineddefault-character-set=utf8

 

mysql添加中文,Data too long for column错误