You are here

MySQL's LOAD DATA INFILE leads to an ERROR 29 (HY000) File not found / (Errcode: 13)

Submitted by Druss on Fri, 2011-09-23 01:08

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 for leaving this - it saved my live now :-)

Gracias por el aporte, excelente

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

The script worked, added "local" on it. THANK YOU!