现象:
更新表字段为中文字符时,提示报错Incorrect string value: '\xE4\xBD\xA0\xE5\xA5\xBD' for column 'description'
修改字符集:
1、查看表字符集
show create table table_name;
发现字符集为latin1,需要修改为utf8
ALTER TABLE hosts DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
只修改表字符集,依旧不可修改为中文字符,还需修改字段字符集
2、查看字段字符集
SHOW FULL COLUMNS FROM table_name;
发现字段字符集都为latin1,需要修改为utf8
ALTER TABLE hosts DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
complete!