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

By Druss , 22 September, 2011

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!

All times are UTC. All content licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.