Import a Single Field Text File into MySQL
I have a text file that looks like this:
value1
value2
value3
There are 32 million lines. Each line is terminated by a \n. The fields are not enclosed or delimited with any characters. I'm trying to import it into MySQL using this code, but it is not working:
LOAD DATA LOCAL INFILE 'data.txt'
INTO TABLE 开发者_运维问答`table`
FIELDS TERMINATED BY ''
ENCLOSED BY ''
LINES TERMINATED BY '\n'
(`column1`)
Can anyone tell me what I'm doing wrong?
Turns out I was being too explicit. This did it:
LOAD DATA LOCAL INFILE 'data.txt'
INTO TABLE `table`
ENCLOSED BY ''
(`column1`)
did you try using double quotes instead of single quotes? it might be interpreting '\n' as a literal - this happens in some other languages and might be the case here
精彩评论