'load data local infile ERROR 2 file not found
I've been ramming my face against this sql error for about 45 minutes, and I have a feeling it's going to be something silly.
I'm trying to load a .txt file into my database, which is on a server elsewhere. I'm using putty on windows 7.
The sql call I am using is the following:
LOAD DATA LOCAL INFILE "C:/Users/Sam/Desktop/students_data.txt" INTO TABLE students;
The response I get is ERROR 2 (HYOOO): File 'C:/Users/Sam/Desktop/students_data.txt' not found (Errcode:2)
If anyone could shed some light on this that'd be extravagant. I already tried switching the /
to \
and using single quotes, etc., but nothing seems to work. The file path is copied by shift+clicking the actual file and pasting it.
Solution 1:[1]
I have found a solution. First delete the word LOCAL from the sql statement. Second - place your file into MySQL DATA folder usually - bin/mysql/msql5.5.8/data/and your DB with which you are working. It worked for me. You might want to check your MAX_FILE upload number in php.ini file if file is large.
Solution 2:[2]
Removing the word LOCAL
seemed to work for me; try it out!
Solution 3:[3]
Try to type path as C:\\mydir\\myfile.csv
i.e. use \\
instead of \
Solution 4:[4]
I had this problem too, then I read this:
The file name must be given as a literal string. On Windows, specify backslashes in path names as forward slashes or doubled backslashes
(from http://dev.mysql.com/doc/refman/5.1/en/load-data.html)
I did use the LOCAL keyword, but escaped the file path like this: str_replace('\\','/',$file)
, then it worked like a charm!
Solution 5:[5]
Had this too and solved it by using cmd.exe and found that the filename was mistakenly in the form filename.txt.txt and fixed it.
Solution 6:[6]
just replace "\" by "/" as the path directory before the filename.txt in (""). it will be better if u just keep the file in mysql data folder and do the thing i mentioned above.it will definitely work.
Solution 7:[7]
Sorry my previous answer is wrong.
In my case, I connect to a proxy, not the real physical mysql instance, so of course it could not get my local file.
To solve this, figure out the true physical mysql instance IP, connect it directly. You need help from the DBA.
Solution 8:[8]
LOAD DATA LOCAL INFILE 'C:\\cygwin\\home\\jml58z\\e_npv\\Fn_awk2010.mysql' INTO TABLE mydata
with the double \ it worked
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | prkarpi |
Solution 2 | |
Solution 3 | Toukenize |
Solution 4 | CragMonkey |
Solution 5 | Parallax |
Solution 6 | Nijhum Reza |
Solution 7 | |
Solution 8 | Jose Maria |