Troubleshooting of Chinese characters inserted in MySQL Command Line

Source: Internet
Author: User
Tags mysql command line

Recently installed MySQL, used UTF-8, key table used UTF-8, encountered the problem of MySQL command line insert Chinese error.

There is no problem in inserting Chinese characters directly in the 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;  
  9.  

But I cannot insert Chinese characters into the MySQL command line.

When the environment is set to UTF8, insertion still fails.

 
 
  1. set names utf8;  
  2.  

Solution:

 
 
  1. Set names gbk;
  2.  
  3. Insert into student (id, name, cardId, age) values ('20160301', 'wei', '20160301', 24 );
  4.  

Successful.

Implementation of MySQL non-repeated Query

Five common MySQL command lines

Troubleshooting of MySQL command line garbled

Two methods to fix mysql tables

How to insert an array into a mysql table in php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.