不能在mysql中插入带有中文字符的记录(错误1366)

时间:2014-04-22 07:49:25

标签: mysql utf-8 mysql-error-1136

在mysql 5.1数据库中,我创建了一个表,     CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

create table users 
(
   Id                   int not null auto_increment comment '主键',
   username             varchar(200) character set utf8 comment '名字',
   password             varchar(200) character set utf8 comment '密码',
   phoneno              varchar(200) character set utf8 comment '电话',
   note                 varchar(200) character set utf8 comment '备注',
   primary key (Id)
);

在Mysql命令行窗口中,我无法插入以下记录。它总是抱怨ERROR:1366不正确的字符串值......

INSERT INTO users (username, password, phoneno, note) VALUES ('张三', '123456', '123456', '我是张三');

问题是什么?

我检查了Mysql配置,它运行正常。

mysql> show variables like '%char%';
+--------------------------+----------------------------------------------------
-----------+
| Variable_name            | Value
           |
+--------------------------+----------------------------------------------------
-----------+
| character_set_client     | utf8
           |
| character_set_connection | utf8
           |
| character_set_database   | utf8
           |
| character_set_filesystem | binary
           |
| character_set_results    | utf8
           |
| character_set_server     | utf8
           |
| character_set_system     | utf8
           |
| character_sets_dir       | C:\Program Files (x86)\MySQL\MySQL Server 5.1\share
\charsets\ |
+--------------------------+----------------------------------------------------
-----------+
8 rows in set (0.00 sec)

0 个答案:

没有答案