日期:2014-05-16  浏览次数:20896 次

菜鸟求问mysql数据插入问题,头晕啊。
表是这样建立的
create table test(
id int(10) not null auto_increment primary key,
name varchar(20) not null,
gender tinyint(1) default 0,
tel int(11) not null)default character set utf8;
我的第一条sql语句:
insert into test(name,gender,tel) values ("小明",1,1233888);
她提示ERROR 1366 (HY000): Incorrect string value:'/xC3/xF7' for column 'name' 1
但我这样时:
insert into test(name,gender,tel) values ("小",1,1233888);
和这样:
insert into test(name,gender,tel) values ("ming",1,1233888);
都插入成功。
但这时我:
insert into test(name,gender,tel) values ("明",1,1233888);
还是提示:ERROR 1366 (HY000): Incorrect string value:'/xC3/xF7' for column 'name' 1这是怎么回事啊?求大牛指点。

------解决方案--------------------
字符集问题

show variables like 'char%';
------解决方案--------------------
set names 'gbk';
insert into test(name,gender,tel) values ("明",1,1233888);


先设置一下字符集。

http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
MySQL 中文显示乱码
------解决方案--------------------
探讨

引用:
引用:

系统默认就那样

我看到别人可以不用这条语句就可以插入啊,是不是可以设置,请赐教。