1 2

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);

提示错误信息:

 

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

alter table table_name(表名) convert to character set utf8 ;

 

posted @ 2019-08-05 17:43  大海的泡沫  阅读(4098)  评论(0编辑  收藏  举报
1 2