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 on
port=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 root
datadir="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 defined
default-character-set=utf8
时间: 2024-08-14 06:02:37

mysql添加中文,Data too long for column错误的相关文章

导入数据的时候,MYSQL 报错:Data too long for column

ERROR 1406 (22001): Data too long for column 解决方法 解决办法: 在my.ini里找到 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 把其中的STRICT_TRANS_TABLES,去掉, 或者把sql-mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 注

mysql添加中文数据失败

日志信息: INFO 2015-01-13 10:44:36,078 org.springframework.beans.factory.xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] INFO 2015-01-13 10:44:36,140 org.springfram

mysql 插入中文报错: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value...

总结写在前面, 总结: 当Java通过jdbc链接mysql插入中文时,要保证程序可以正常执行,而且插入的中文不会乱码, mysql服务器端,对数据表(不是数据库)的编码设置,要保证是支持中文的,例如gbk, gb2312, utf-8 jdbc的连接配置,要开启useUnicode=true,并且要设置一个支持中文的编码,不需要跟mysql表的编码保持一致,只需要支持中文就行.例如characterEncoding=utf8 本身的Java文件的编码需要支持中文 ===============

插入中文错误ERROR 1406 (22001): Data too long for column 'name' at row 1

1.在导入数据前执行以下命令即可:set SESSION sql_mode=''; 通过设置sql_mode变量更改模式.linux下安装完mysql后,默认的sql-mode值是空,在这种情形下mysql执行的是一种不严格的检查,例如日期字段可以插入’0000-00-00 00:00:00’这样的值,还有如果要插入的字段长度超过列定义的长度,那么mysql不会终止操作,而是会自动截断后面的字符继续插入操作. 但是如果我们本意希望如果长度超过限制就报错,那么我们可以设置sql_mode为STRI

sql点滴37—mysql中的错误Data too long for column '' at row 1

原文:sql点滴37-mysql中的错误Data too long for column '' at row 1   1.MYSQL服务 我的电脑——(右键)管理——服务与应用程序——服务——MYSQL——开启(停止.重启动) 2.命令行方式 Windows 1.点击“开始”->“运行”(快捷键Win+R). 2.启动:输入 net stop mysql 3.停止:输入 net start mysql 提示* Redhat Linux 也支持service command,启动:# servic

mysql 插入中文字段报错 "Incorrect string value: '\\xE6\\xB5\\x8B\\xE8\\xAF\\x95...' for column 'title' at row 1"

1. 查看一个 database 或一个 table 的编码show create database mytestdb;show create table testapp_article; mysql> show create table testapp_article;+-----------------+-----------------------------------------------------------------------------------------------

mysql Out of range value adjusted for column导致Warning(1265)Data truncated for column 'column_name' at row 1

今天下午,我们的一个开发来找我,说线上有个环境报了"Warning(1265)Data truncated for column 'column_name' at row 1",定义的字段长度decimal(32,4),实际的小数点有超过4位的,但是大部分的账户登录查询的时候都没有问题,已知的就一个账户进行查询的时候会出现这个问题,看数据没有什么特别异常的. 于是,过去协助排查,临时拷贝了个存储过程,还真蹊跷,查询其他数据都没有问题,但是一到这一条记录就报错,在update报错的语句前

Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'content' a

1.错误描述 org.hibernate.exception.DataException: could not execute statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:69) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert

[MySQL] Data too long for column 'title' at row 1

李刚轻量级JavaEE第六章的坑..艹李刚自己有没试过这些代码的啊,6.4这一份HqlQuery.java里需要的表,根本就跟他提供的sql脚本对不上啊..坑爹啊,而且字符编码集也有问题. 出现这个原因是编码不统一的问题. 首先字符编码集有GBK.GB2312.UTF8,区别详见 http://down.chinaz.com/server/201111/1423_1.htm 再看了手头上的一些源代码,结论是,感觉用utf8比较合适 那出现这个问题如何修复 1.查看一下MySQL的编码集,在MyS