mysql 当插入中文字段时发生“data too long for column”错误
2010-04-01 21:16
621 查看
从MySql5中运行本地脚本创建数据库,当插入中文字段时发生“data too long for column”错误。上网一查,发现多字节用户大都碰到了这种情况。google搜索网上的解决方法大都是要将数据库的编码方式为GBK或UTF8,可我在安装MySql时就选择了UTF8格式。解决方法是:数据库目前是utf-8 ,为了能插入中文,先暂时把
mysql5的my.ini里的一个编码改成gbk,然后插入进去就可以了,如果用mysql自己的那个dos界面查看的话,可能显示是乱码,没关系,然后关闭
mysql服务,重新设置mysql的编码为utf8,然后重启服务器,用navicat这样的工具查看,应该能看到正确的编码,尔不是乱码,这样就可以解决了
# 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 on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/MySQL/MySQL Server 5.0/"
#Path to the database root
datadir="D:/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 defined
default-character-set=utf8
重启下就OK了
mysql5的my.ini里的一个编码改成gbk,然后插入进去就可以了,如果用mysql自己的那个dos界面查看的话,可能显示是乱码,没关系,然后关闭
mysql服务,重新设置mysql的编码为utf8,然后重启服务器,用navicat这样的工具查看,应该能看到正确的编码,尔不是乱码,这样就可以解决了
# 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 on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/MySQL/MySQL Server 5.0/"
#Path to the database root
datadir="D:/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 defined
default-character-set=utf8
重启下就OK了
相关文章推荐
- mysql 当插入中文字段时发生“data too long for column”错误
- MYSQL写入中文错误 —— Data too long for column 'xxx' at row 1
- MySQL插入中文时出现ERROR 1406 (22001): Data too long for column 'name' at row 1
- MySql中插入中文数据提示Data too long for column X at row n的解决
- MySQL插入中文时出现ERROR 1406 (22001): Data too long for column 'name' at row 1
- 读取MYSQL中文数据乱码,解决data too long for column 'title' at row 1
- mysql 数据库 错误 Data truncation: Data too long for column 'name' at row 1
- sql点滴37—mysql中的错误Data too long for column '' at row 1
- sql点滴37—mysql中的错误Data too long for column '' at row 1
- MySQL字符集 GBK、GB2312、UTF8区别 解决 MYSQL中文乱码问题以及error 1406:data too long for column 'name' at row 1
- mysql中存中文时出现“Data too long for column”
- jdbc 连mysql 时报 Data too long for column 'name' at row 1 错误
- MySQL中文字符解决方案[Data too long for column XX at row n]
- MySQL中导入中文字符解决方案[Data too long for column XX at row n] 分类: 数据库 2012-11-02 14:30 1286人阅读 评论(0) 收藏
- 读取MYSQL中文数据乱码,解决data too long for column 'title' at row 1
- jdbc 连mysql 时报 Data too long for column 'name' at row 1 错误
- (转载)MySQL中导入中文字符解决方案[Data too long for column XX at row n]
- MySQL中导入中文字符解决方案[Data too long for column XX at row n]
- ssh框架中的错误:com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'user_name'
- MySQL中文字符解决方案[Data too long for column XX at row n]