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

9

7

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?

Responsiveness answered 22/4, 2014 at 23:59 Comment(1)
If given as a relative path name, the name is interpreted relative to the directory in which the client program was started. [dev.mysql.com/doc/refman/5.5/en/load-data.html]Excrescent
A
4

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.

Agrigento answered 23/4, 2014 at 0:26 Comment(0)
V
7

I spent 2 days on this and finally got my mistake, Just changing backslashes by forward ones, as one contributor previously said. And finally worked for me. so was:

LOAD DATA LOCAL INFILE 'C:/ProgramData/MySQL/MySQL Server 5.7/Data/menagerie/pet.txt' INTO TABLE pet;

I just can say thanks a lot.

p.s. don't waste time on ytb...

Valor answered 18/3, 2017 at 18:13 Comment(0)
A
4

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.

Agrigento answered 23/4, 2014 at 0:26 Comment(0)
H
2

If using MySQL Workbench on a local Windows PC to connect to a remote MySQL server,

  1. Add the "LOCAL" keyword
  2. Add double backslashes "\\" to your folder path

If text file's first row has column names add "IGNORE 1 LINES".

LOAD DATA LOCAL INFILE 'C:\\MyTabDelimited.txt'
INTO TABLE my_table IGNORE 1 LINES;
Hayseed answered 18/5, 2016 at 17:44 Comment(0)
E
1

Simply replace backslash with slash in the path. This works for me (MySQL Workbench 6.3 on Win 10):

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

Ref. https://dev.mysql.com/doc/refman/5.5/en/loading-tables.html

Excrescent answered 7/2, 2017 at 22:1 Comment(0)
S
1

One more reason for this type of error is another languge in the path. You might have almost the entire path in English, but the username might be auto-filled in another language.

Solangesolano answered 14/1, 2023 at 14:2 Comment(0)
L
0

Try removing the word LOCAL from your query.

Lipchitz answered 23/4, 2014 at 0:4 Comment(0)
M
0

Try moving the week.txt file to the desktop

then execute in a terminal window:

LOAD DATA LOCAL INFILE 'C:\Users\Myself\Desktop\week.txt' 
INTO TABLE week;
Mcclean answered 30/1, 2016 at 1:56 Comment(0)
A
0

Instead of using double backslash That slash is also worked for me too.

Anatropous answered 5/1, 2020 at 17:59 Comment(0)
E
0

I resolve this problem by replacing the path

Replace format "C:\Users\Myself\Desktop\week.txt"

With this different format "C:/Users/Myself/Desktop/week.txt"

My computer didnt recognize the ( \ ) symbols.

Engagement answered 18/8, 2021 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.