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.
- 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;
-
But I cannot insert Chinese characters into the MySQL command line.
When the environment is set to UTF8, insertion still fails.
- set names utf8;
-
Solution:
- Set names gbk;
-
- Insert into student (id, name, cardId, age) values ('20160301', 'wei', '20160301', 24 );
-
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