load data local infile ERROR 2 file not found

34,735

Solution 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

Removing the word LOCAL seemed to work for me; try it out!

Solution 3

Try to type path as C:\\mydir\\myfile.csv i.e. use \\ instead of \

Solution 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

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.

Share:
34,735

Related videos on Youtube

samuel
Author by

samuel

I've been teaching myself html, css, javascript (primarily through jQuery), php, and mysql for the better part of a year. I'm currently working as a developer for the Center for Empirical Research in the law, coming up with interesting ways to display empirical data that the law professors come across. I've got another year left at Washington University in St. Louis, where I'll be graduating with a degree in Psychology (though I appear to be headed down quite the different career track). I play a solid number of video games and read whenever I get the chance. If you've read a book or played a game that's caused some sort of stirrings in your soul let me know and I'll tack it onto my list.

Updated on April 22, 2022

Comments

  • samuel
    samuel about 2 years

    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.

  • saikiran
    saikiran about 10 years
    i am working with MySQL and the first solution is okay.. but why we need php.ini file and where can i found php.ini, @prkarpi
  • saikiran
    saikiran about 10 years
    Have done the above procedure still facing the error.. given file permissions to full control and copied file to c>programdata>mysql>mysqlserver 5.6>data>sample . please help.
  • saikiran
    saikiran about 10 years
    my file is nearly has 2 GB of data.
  • luckyfox
    luckyfox over 4 years
    if your are in Windows, same way.