表是这样建立的
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这是怎么回事啊?求大牛指点。
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这是怎么回事啊?求大牛指点。
没问题啊
insert into test(name,gender,tel) values ("明",1,1233888);
先设置一下字符集。http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
MySQL 中文显示乱码
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.19 MySQL Community Server (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trade of Oracle Corporation and/or its
affiliates. Other names may be trades of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database test;
Query OK, 1 row affected (0.00 sec)mysql> use test;
Database changed
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;
Query OK, 0 rows affected (0.04 sec)mysql> insert into test(name,gender,tel) values ("小明",1,1233888);
Query OK, 1 row affected (0.00 sec)mysql> insert into test(name,gender,tel) values ("小",1,1233888);
Query OK, 1 row affected (0.00 sec)mysql> insert into test(name,gender,tel) values ("ming",1,1233888);
Query OK, 1 row affected (0.00 sec)mysql> insert into test(name,gender,tel) values ("明",1,1233888);
Query OK, 1 row affected (0.00 sec)mysql>没有任何问题啊
insert into test(name,gender,tel) values ('小明',1,1233888);
和
insert into test(name,gender,tel) values ("明",1,1233888);
单引号和双引号都可以的。
mysql> SHOW TABLE STATUS FROM test \G;
*************************** 1. row ***************************
Name: test
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 4
Avg_row_length: 4096
Data_length: 16384
Max_data_length: 0
Index_length: 0
Data_free: 7340032
Auto_increment: 5
Create_time: 2012-05-17 13:15:02
Update_time: NULL
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)ERROR:
No query specifiedmysql> desc test;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| gender | tinyint(1) | YES | | 0 | |
| tel | int(11) | NO | | NULL | |
+--------+-------------+------+-----+---------+----------------+
4 rows in set (0.06 sec)我发现我说错了,所以后面附了帖子#7说明了一下
big5 | Big5 Traditional Chinese
gb2312 | GB2312 Simplified Chinese
gbk | GBK Simplified Chinese
utf8 | UTF-8 Unicode 2. 确保,联接参数与这个字段字符集一致,你可以用 set name 'charsetname';
比如, set name 'gbk';
这条命令会同时修改 character_set_client,character_set_connection,character_set_results
(如果你的这架MySQL中都为中文,则你可以在my.ini或my.cnf中加上或修改这个参数, 参数文件修改后需重启MySQL服务)
[mysql]
default-character-set=gbk
百度来的,我先下线了
fangzhaoguo
(古古_怪怪)