MySQL insert statement execution error ERROR1366, incorrect string value

ERROR 1366 (HY000): Incorrect string value: '\xC1\xF5\xB5\xC2\xBB\xAA' for column 'sname' at row 1

After I perform such a simple statement of the above error

mysql> insert into student values('刘德华',100124,1,null,'声乐192班');

The table design is this.

I inquired about the structure and see the character set table is Latin1

So what changes the character set

mysql> alter table student character set utf-8;

Re-execute the insert statement, or the original discovery of the error, it is once again the query table structure, changes in the discovery table, two fields again

They changed my eleven

mysql> alter table student modify sname  varchar(20)  character set gbk;
mysql> alter table student modify class varchar(20)  character set gbk;

Continue insert statement, inserted successfully, and then view the table data confirmation.

 

 

 

Published 35 original articles · won praise 30 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43792401/article/details/102100182