MySQL is inserted into the Chinese encoding errors: ERROR 1366 (HY000): Incorrect string value: '' for column '' at row 1

Transfer: https://my.oschina.net/gwlCode/blog/3004454

When insert data

insert into account values(null,'名字',5000);

Suggest the following error

ERROR 1366 (HY000): Incorrect string value: '\xE5\x90\x8D\xE5\xAD\x97' for column 'name' at row 1

View Data Encoding

show create table account;

Modify Data Encoding

alter table account character set utf8;

Coded view the modified

show create table account;

At this time table has been modified to encode UTF8, but not name lantin1, as will insert data errors, the need to modify the field coding

Format: alter table table name field name field name change character set utf8 not null varchar (50);

alter table account change name name varchar(50) character set utf8 not null;

Revised as follows

Guess you like

Origin www.cnblogs.com/linwenbin/p/11448700.html