Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 14:51:46
Original
1027 people have browsed it

最近安装MySQL,使用了UTF-8 ,键表使用了UTF-8,遇到了MySQL命令行插入中文出错的问题。 在Query Browser中直接插入中文没有问题. createtablestudent( idvarchar(100)notnulldefault'', namevarchar(20)default'', cardIdvarchar(20)notnulldefault'', age

  最近安装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);  

  成功.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!