MySQL LOAD DATA Error (Errcode: 2 - "No such file or directory")

Solace picture Solace · Apr 23, 2014 · Viewed 32.2k times · Source

I am trying to load data into a table of my MySQL database, and getting this error.

LOAD DATA LOCAL INFILE 'C:\Users\Myself\Desktop\Blah Blah\LOAD DATA\week.txt' 
INTO TABLE week;

Reference: this

The path is hundred percent correct, I copied it by pressing shift and clicking "copy path as" and checked it many times. So any tips on this will be much appreciated. . My research: Seeing this answer, I tried by changing C:\Users to C:\\Users. It did not work for me.

Secondly, is there a way to use some kind of a relative path (rather than an absolute path) here?

Answer

FumblesWithCode picture FumblesWithCode · Apr 23, 2014

I don't know what version of MySQL you are using but a quick Google search found possible answers to both your questions. Below are excerpts from the MySQL 5.1 Reference Manual:

The file name must be given as a literal string. On Windows, specify backslashes in path names as forward slashes or doubled backslashes

The LOCAL keyword affects where the file is expected to be found:

If LOCAL is specified, the file is read by the client program on the client host and sent to the server. The file can be given as a full path name to specify its exact location. If given as a relative path name, the name is interpreted relative to the directory in which the client program was started.

Regards.