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!
- Log in to post comments
Comments
Thx a lot
Thx for leaving this - it saved my live now :-)
Glad to hear it :)
Glad to hear it :)
Muy bueno
Gracias por el aporte, excelente
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!
MySQL Load Data Infile Error(29) File not found errorcode(2)
Adding Local did not work for me. The file.txt is in the root directory of the computer it is in the Data subdirectory and in the database directory. All of the access is set to all for NETWORK SERVICE.
Worked
The script worked, added "local" on it. THANK YOU!