Mysql向新建表中插入数据, Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'UserName' at row 1

在本地经过MYSQL建立测试表测试

CREATE Table User (
    UserId int not NULL PRIMARY KEY auto_increment,   //主键自增
   UserName VARCHAR(10) not null,
    Pwd VARCHAR(20) not NULL,
    Age int not null
);

而后插入数据的时候:编码

INSERT into USER(UserName,Pwd,Age) VALUES('李四','dasfasf',40);

提示错误信息:spa

 

ERROR 1366 (HY000)错误类型 
在插入中文时,报错显示这种错误,是由于编码的问题,应该选择utf8类型编码.用如下编码就能解决: code

alter table table_name(表名) convert to character set utf8 ;
相关文章
相关标签/搜索