MySQL命令行插入中文出错的解决

最近安装MySQL,使用了UTF-8 ,键表使用了UTF-8,遇到了MySQL命令行插入中文出错的问题。

创新互联建站是一家专业提供海勃湾企业网站建设,专注与网站建设、成都网站建设、H5技术、小程序制作等业务。10年已为海勃湾众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

在Query Browser中直接插入中文没有问题.

 
 
 
  1. create table student(
  2. id varchar(100) not null default '',
  3. name varchar(20) default '',
  4. cardId varchar(20) not null default '',
  5. age int(3) default '0',
  6. primary key (id),
  7. unique key (cardId)
  8. )engine=InnoDB default charset=utf8;

但是在MySQL命令行中插入中文,居然不行.

设置环境为UTF8,插入仍然失败.

 
 
 
  1. set names utf8;

解决:

 
 
 
  1. set names gbk;
  2. insert into student(id,name,cardId,age) values('1234','伟','05120492',24);

成功.


网站题目:MySQL命令行插入中文出错的解决
网页URL:http://csdahua.cn/article/ccscdep.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流