最近安装MySQL,使用了UTF-8 ,键表使用了UTF-8,遇到了MySQL命令行插入中文出错的问题 。
在Query Browser中直接插入中文没有问题.
- create table student(
- id varchar(100) not null default ,
- name varchar(20) default ,
- cardId varchar(20) not null default ,
- age int(3) default 0,
- primary key (id),
- unique key (cardId)
- )engine=InnoDB default charset=utf8;
-
但是在MySQL命令行中插入中文,居然不行.
设置环境为UTF8,插入仍然失败.
- set names utf8;
-
解决:
- set names gbk;
-
- insert into student(id,name,cardId,age) values(1234,伟,05120492,24);
-
成功.