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

笑着哭i 提交于 2019-11-29 11:12:43

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.

Mario Vandeersar

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...

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;

Try removing the word LOCAL from your query.

Mohan S

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;

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!