使用utf8编码直接建立数据库无法插入中文,需要做些调整。用set names '字符集' 将character_set_client、 character_set_results和character_set_connection设置为GBK,需要插入中文的列声明为varchar类型即可插入中文字符。格式为:
set names='字符集'
例如:
create table if not exists customer
(
SFZH char(18) not null unique,
XM varchar(30),
ZH char(16) not null
);
delete from customer;
insert
into customer
values('123456781234567890','刘平,'6224321207808899');
可以用show variables like 'character%'查看字符集情况。