今天在自己的window8.1系统上安装了Mysql v5.0,完成后用Navicat for MySQL连接了一下,并在默认的test库下创建表插入数据。结果在插入数据的时候有如下信息
[SQL] DROP TABLE IF EXISTS t_project;
受影响的行: 0
时间: 0.000ms
[SQL]
CREATE TABLE t_project (
t_id int(11) NOT NULL AUTO_INCREMENT,
t_no char(8) DEFAULT NULL,
t_name varchar(50) DEFAULT NULL,
t_start_date date DEFAULT NULL,
t_end_date date DEFAULT NULL,
PRIMARY KEY (t_id)
) ENGINE=InnoDB ;
受影响的行: 0
时间: 0.354ms
[SQL]
INSERT INTO t_project
VALUES (97,'pm000001','上山寻找老虎','2008-01-02','2008-01-15');
[Err] 1406 - Data too long for column 't_name' at row 1
这段sql语句我很久之前执行过,并无问题,于是开始查找原因
有人说可能是数据库编码的问题,于是查了下编码:
mysql> show variables like 'character_set_database';
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| character_set_database | latin1 |
+------------------------+--------+
1 row in set (0.00 sec)
这里编码是latin1编码
更改数据库编码
mysql> alter database test CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
再次查看test库编码
mysql> show variables like 'character_set_database';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| character_set_database | utf8 |
+------------------------+-------+
1 row in set (0.00 sec)
重新执行sql语句
mysql> CREATE TABLE t_project (
-> t_id int(11) NOT NULL AUTO_INCREMENT,
-> t_no char(8) DEFAULT NULL,
-> t_name varchar(50) DEFAULT NULL,
-> t_start_date date DEFAULT NULL,
-> t_end_date date DEFAULT NULL,
-> PRIMARY KEY (t_id)
-> ) ENGINE=InnoDB ;
Query OK, 0 rows affected (0.09 sec)
mysql> INSERT INTO t_project
-> VALUES (97,'pm000001','上山寻找老虎','2008-01-02','2008-01-15');
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO t_project
-> VALUES (98,'pm000002','上班赚钱喂老虎吃肉','2008-02-01','2008-02-20');
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO t_project
-> VALUES (99,'pm000003','骑着老虎上街溜达','2008-03-01','2008-03-08');
Query OK, 1 row affected (0.05 sec)
mysql> INSERT INTO t_project
-> VALUES (100,'pm000004','让老虎咬我不喜欢的人','2008-03-08','2008-03-10');
Query OK, 1 row affected (0.03 sec)
mysql> INSERT INTO t_project
-> VALUES (167,'pm000071','name0968058634','2008-05-28','2008-08-26');
Query OK, 1 row affected (0.06 sec)
mysql> INSERT INTO t_project
-> VALUES (168,'pm000072','name1255323646','2008-11-05','2009-01-17');
Query OK, 1 row affected (0.03 sec)
mysql> INSERT INTO t_project
-> VALUES (197,'pm000101','和老虎喝着咖啡彻夜长谈','2008-01-01','2008-02-02'
);
Query OK, 1 row affected (0.04 sec)
mysql> #
mysql> # Table structure for table t_user
mysql> #
mysql> DROP TABLE IF EXISTS t_user;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE TABLE t_user (
-> t_id int(11) NOT NULL AUTO_INCREMENT,
-> t_loginname varchar(50) DEFAULT NULL,
-> t_password varchar(50) DEFAULT NULL,
-> t_name varchar(100) DEFAULT NULL, ##真实姓名
-> PRIMARY KEY (t_id)
-> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.12 sec)
mysql> INSERT INTO t_user(t_loginname, t_password, t_name)
-> VALUES ('dachui','12345','goodman');
Query OK, 1 row affected (0.06 sec)
结论:是数据库编码导致了[Err] 1406 - Data too long for column 't_name' at row 1
分享到:
相关推荐
解决办法: 在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_...
centos6,linux系统,rpm资源:libcom_err-devel-1.41.12-24.el6.x86_64.rpm
libcom_err-1.41.12-23.el6.x86_64.rpm libcom_err-1.41.12-23.el6.x86_64.rpm
centos6,linux系统,rpm资源:libcom_err-1.41.12-24.el6.x86_64.rpm
离线安装包,亲测可用
离线安装包,亲测可用
libcom_err-devel-1.42.9-19.el7.i686.rpm
e2fsprogs-1.42.9-19.el7.x86_64
错误 101 (net--ERR_CONNECTION_RESET).docx
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
刚开始学习数据库操作,今天存数据时发现,保存的时候报错(Error 1292: Incorrect datetime value: '0000-00-00' for column 'deleted_at' at row 1) ,之后就搜索了下原因,是因为MySQL存日期时不允许出现这种格式...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
if(mcpd_igmp_proxy_init() != MCPD_RET_OK) { MCPD_TRACE(MCPD_TRC_ERR "mcpd_igmp_proxy_init failed\n");
if(isset($_FILES['filename']) && $_FILES['filename']['error'] === UPLOAD_ERR_OK) { $target_dir = 'uploads/'; $target_file = $target_dir . basename($_FILES['filename']['name']); $file_type = path...
linux 离线安装gcc++ (简单易懂,已成功安装): autogen-libopts-5.18-5.el7.x86_64.rpm ...libcom_err-1.42.9-11.el7.x86_64.rpm libselinux-devel-2.5-12.el7.x86_64.rpm libsepol-devel-2.5-8.1.el7.x86_64.rpm ...
需要先安装完破解补丁,将Launcher.cmd放到游戏根目录和launcher.exe一起。通过管理员权限打开Launcher.cmd来启动游戏。
# CrashAnalysis ...java -jar CrashAnalysis-1.0-SNAPSHOT.jar ${hs_err_pid.log} ${hs_err_pid.log} 是jvm crash后生成的日志。 ## 效果 分析完成后会展示出来诊断信息,其他信息都是用来验证诊断信息的。
Generate the code for adding user defined Gaussian Noise (in dB) and a. Filter out the same using average filter (generate function) b. Determine the frequency plot c. Determine error image, SNR and ...
[client] port=3306 [mysql] no-beep default-character-set=utf8 [mysqld] datadir=D:/Data port=3306 server-id=...log_file_size=1G innodb_log_buffer_size=8M innodb_flush_log_at_trx_commit=2 innodb_file_per_t