While trying to import a CSV file into MySQL today using the LOAD DATA INFILE command, I ran into the following situation:
mysql> LOAD DATA INFILE 'foo.csv' INTO TABLE bar FIELDS TERMINATED BY ',' ENCLOSED BY '#' LINES TERMINATED BY '\r' (a, b);
ERROR 29 (HY000): File 'foo.csv' not found (Errcode: 13)
The file exists fine and the permissions are also kosher. After much gnashing of teeth and perusing of documentation, I found out that local file sources require the LOCAL keyword:
mysql> LOAD DATA LOCAL INFILE 'foo.csv' INTO TABLE bar FIELDS TERMINATED BY ',' ENCLOSED BY '#' LINES TERMINATED BY '\r' (a, b);
Query OK, 365 rows affected, 0 warnings (0.10 sec)
Hope this helps!
Comments
Thx a lot
Thx for leaving this - it saved my live now :-)
Glad to hear it :)
Glad to hear it :)
awesome, thanks for the post.
awesome, thanks for the post... i knew about local, but for some reason spaced it off and just spent half an hour fiddling with permissions
Thanks for the comment - I'm
Thanks for the comment - I'm happy to hear that the post helped!