整整折腾了两天终于知道怎么让mysql中的表中输入中文数据了。现将方法记录下来: mysql
在my.ini中default-character-set=latin1,代表通常默认的数据库的字符集为latin字符集,不支持中文。 sql
建立表时,表或表中的列若是没有显示代表使用的字符集,则采用数据库的字符集。 数据库
例如: spa
create table test(ch varchar(30)); string 插入数据:insert into test values("中石化"); table 则提示错误: test Error Code: 1366 |
但若是将表改成:alter table tablename convert to character set utf8; 数据
在执行刚才的插入语句,则成功。 tab
若是还不行的话,能够:alter table test modify ch archar(30) character set utf8;