Incorrect string value: 'xE5x95x8AxE5x8FxAF...' for column 'detect_name' at row 1
首先找到对应表,执行show create table table_name ;
查看表的详细信息
例如:
CREATE TABLE `b_event_detect` ( `detect_id` int(11) NOT NULL AUTO_INCREMENT, `topological_id` int(11) DEFAULT NULL, `detect_name` varchar(128) CHARACTER SET latin1 DEFAULT NULL, `detect_type` varchar(20) CHARACTER SET latin1 DEFAULT NULL COMMENT '0:default_event;1:app_monitor;2:host_action;3:network_generate;4:network_rule;5:total_rule;11:real_log', `port` int(11) DEFAULT NULL, `keyword` varchar(1024) CHARACTER SET latin1 DEFAULT NULL, `node_id` bigint(20) DEFAULT NULL, `interface_id` bigint(20) DEFAULT NULL, `states` varchar(50) CHARACTER SET latin1 DEFAULT NULL, `trafficsave_flag` varchar(50) CHARACTER SET latin1 DEFAULT NULL, `trafficcollection_flag` varchar(50) CHARACTER SET latin1 DEFAULT NULL, PRIMARY KEY (`detect_id`) ) ENGINE=MyISAM AUTO_INCREMENT=19198 DEFAULT CHARSET=utf8
查看表的最末尾表的字符集格式和每个字段的字符集格式
如果有问题的改成utf-8
修改数据库字符集:
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...]
如:ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
只是修改表的默认字符集:
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE...];
如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
修改字段的字符集:
ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...];
如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
查看数据库编码:
SHOW CREATE DATABASE db_name;
查看表编码:
SHOW CREATE TABLE tbl_name;
查看字段编码:
SHOW FULL COLUMNS FROM tbl_name;
查看系统的编码字符
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
MySQL字符集设置
完美解决bug