Reputation: 757
I am trying to import my data form text file into mysql database. I used the LOAD DATA INFILE statement but it does not work successfully.
My text file is as follows with fields terminated by '\t' and lines terminated by '\n':
2102308562 2102298734 2 75
2102308562 2409206932 2 15
2102308562 1706425142 2 9
2102308562 2817061695 2 6
2102308562 1738818365 2 52
2102308562 2102304314 2 16
2102308562 1732994262 2 2
2102308562 1952263417 2 1
The table I want to insert is defined by the following statement:
CREATE TABLE `t_user_action` (
`Subject_user_id` INT(32) UNSIGNED NOT NULL COMMENT ,
`Object_user_id` INT(32) UNSIGNED NOT NULL COMMENT ,
`Action_id` INT(32) UNSIGNED NOT NULL COMMENT ,
`Action_count` INT(32) UNSIGNED NOT NULL COMMENT ,
PRIMARY KEY (`Subject_user_id`,`Object_user_id`,`Action_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
My import statement is like that:
LOAD DATA INFILE 'UserRetweet.txt' INTO TABLE t_user_action CHARACTER SET utf8
My problem is that after the load data infile statement executed. The value of the first column in the first row becomes 0, but other values are right.
I've searched on the Internet and can not get a solution! Thanks for any advice!
Upvotes: 0
Views: 373
Reputation: 587
You probably have Byte Order Mark at the beginning of your UTF-8 file.
Upvotes: 4