mysql> alter table recommend convert to character set utf8;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> LOAD DATA INFILE 'D:/train_data.txt'
-> INTO TABLE recommend
-> FIELDS TERMINATED BY ' '
-> LINES TERMINATED BY '\n'
-> ignore 1 lines
-> (userid,newsid,readtime,title,content,newstime);
ERROR 1366 (HY000): Incorrect string value: '\xE5\xBE\x81\xE5\x9C\xB0...' for co
lumn 'content' at row 23270
mysql> alter table recommend convert to character set gbk;
Query OK, 0 rows affected (0.10 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> LOAD DATA INFILE 'D:/train_data.txt'
-> INTO TABLE recommend
-> FIELDS TERMINATED BY ' '
-> LINES TERMINATED BY '\n'
-> ignore 1 lines
-> (userid,newsid,readtime,title,content,newstime);
ERROR 1366 (HY000): Incorrect string value: '\xEE\x80\x907%\xE7...' for column '
content' at row 1810
mysql> alter table recommend convert to character set utf8mb4;
Query OK, 0 rows affected (0.10 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> LOAD DATA INFILE 'D:/train_data.txt'
-> INTO TABLE recommend
-> FIELDS TERMINATED BY ' '
-> LINES TERMINATED BY '\n'
-> ignore 1 lines
-> (userid,newsid,readtime,title,content,newstime);
Query OK, 116224 rows affected (21.75 sec)
字符串一直有问题,utf8,gbk 中文都有问题,可能是特殊符号。最后设置为
alter table recommend convert to character set utf8mb4;
解决问题。
在一开始的时候,错误一直是integer整形不匹配问题,第一行的第一个数字会在前面多插入一个空格,使得不能存入int中,解决方法是忽略第一行,然后自己手动加。。