日期:2014-05-19  浏览次数:20527 次

mysql错误
代码:create database bbs;

use bbs;

create table article 
(
id int primary key auto_increment,
pid int,
rootid int,
title varchar(255),
cont text,
pdate datetime,
isleaf int 
);

insert into article values (null, 0, 1, '蚂蚁大战大象', '蚂蚁大战大象', now(), 1);
insert into article values (null, 1, 1, '大象被打趴下了', '大象被打趴下了',now(), 1);
insert into article values (null, 2, 1, '蚂蚁也不好过','蚂蚁也不好过', now(), 0);
insert into article values (null, 2, 1, '瞎说', '瞎说', now(), 1);
insert into article values (null, 4, 1, '没有瞎说', '没有瞎说', now(), 0);
insert into article values (null, 1, 1, '怎么可能', '怎么可能', now(), 1);
insert into article values (null, 6, 1, '怎么没有可能', '怎么没有可能', now(), 0);
insert into article values (null, 6, 1, '可能性是很大的', '可能性是很大的', now(), 0);
insert into article values (null, 2, 1, '大象进医院了', '大象进医院了', now(), 1);
insert into article values (null, 9, 1, '护士是蚂蚁', '护士是蚂蚁', now(), 0);

错误:
  ERROR 1366 (HY000): Incorrect string value: '\xC2\xEC\xD2\xCF\xB4\xF3...' for co
lumn 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xB4\xF3\xCF\xF3\xB1\xBB...' for co
lumn 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xC2\xEC\xD2\xCF\xD2\xB2...' for co
lumn 'title' at row 1
Query OK, 1 row affected (0.00 sec)

ERROR 1366 (HY000): Incorrect string value: '\xD3\xD0\xCF\xB9\xCB\xB5' for colum
n 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xD4\xF5\xC3\xB4\xBF\xC9...' for co
lumn 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xD4\xF5\xC3\xB4\xC3\xBB...' for co
lumn 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xBF\xC9\xC4\xDC\xD0\xD4...' for co
lumn 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xB4\xF3\xCF\xF3\xBD\xF8...' for co
lumn 'title' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xBB\xA4\xCA\xBF\xCA\xC7...' for co
lumn 'title' at row 1
mysql>

------解决方案--------------------
字符集不匹配
------解决方案--------------------
你建表的时候加上这句话。engine=InnoDB default charset=gb2312;
保证就可以向表中插入中文了。