MySQL cannot find data file for a load operation

David picture David · May 23, 2011 · Viewed 16.6k times · Source

I would like to load a data file into MySQL using the following command:

LOAD DATA LOCAL INFILE '/Users/David/Desktop/popularity20110511/test_data' INTO TABLE test_table

The above command gives me the following error:

#7890 - Can't find file '/Users/David/Desktop/popularity20110511/test_data'.

I've also tried:

LOAD DATA INFILE '/Users/David/Desktop/popularity20110511/test_data' INTO TABLE test_table

I also gives me an error:

#13 - Can't get stat of '/Users/David/Desktop/popularity20110511/test_data' (Errcode: 13)

I've repeatedly checked the file path and name and I've also made sure the file privilege is set to Read & Write for everyone.

I am using a Mac and phpMyAdmin.

Any suggestions on what the problem may be?

Answer

Alexandre Crivellaro picture Alexandre Crivellaro · Apr 23, 2013

I had the same problem using MacOs and tried to change permissions, etc, but I realized you have to use the same directory structure you have using in the Terminal Application. Example: if you have (localhost/myproject/myfile.csv) try using

(Applications/XAMPP/htdocs/myproject/myfile.csv).
LOAD DATA LOCAL INFILE '/Applications/XAMPP/htdocs/myproject/myfile.csv' 
INTO TABLE `mytable` 
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\r';