Sunday, April 17, 2005

LOAD DATA INFILE example - importing data from csv into mysql

LOAD DATA INFILE "/home/mysql/data/my_table.csv" INTO TABLE my_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';

7 comments:

MDM said...

Very good tip! Thanks!!

Anonymous said...

Thanks a lot.

Jason said...

Thanks very much. Very useful example.

Arend van der Kolk said...

simple but excellent in the eyes of a newbie, ;-) thx

check odds said...

but that path with home what it means? where i need to place that file to take it?

Anonymous said...

But I got an error message:
ERROR 13 (HY000): Can't get stat of '/var/lib/mysql TAIR10_functional_descriptions_no_headers.txt.tab' (Errcode: 2)

It is said related to the permission issue to mysql client or the user when I googled, but I checked the permission, it is rw-. Any clue? Thanks a lot!

Anonymous said...

Thank you so much - very helpful! My loaded csv file data was appearing as zeroes and nulls until I read this blog and realised I hadn't specified the comma delimiter.