1

I've created a file: 'C:\fff.txt' which contains data for my database table. Then I'm trying to load data from that file like this:

LOAD DATA LOCAL INFILE 'C:\\fff.txt' INTO TABLE fff
LINES TERMINATED BY '\r\n'; 

but I get the following error all the time:

ERROR 2 <HY000>: File 'C:\fff.txt' not found (OS errno 2 - No such file or directory)

I've added local_infile=1 to [mysql] and [mysqld] sections of my.ini file. When I type: SHOW GLOBAL VARIABLES LIKE 'local_infile'; I can see that it's set to 'ON'. Is there a way to solve this problem?

1
  • 1
    I closed this as "too localized" since the problem was the file name. From a comment by @JConstantine on the answer below: "The problem is solved for me. It was my bad. I did not notice that the name of the file was pet.txt.txt instead of pet.txt" – Max Vernon Dec 3 '20 at 3:44
1

Windows restricts the acces for that folder.

Best is to create a separate folder and give it the right access rights.

I tried a lot but i can't replicate your message, when the file exists it can open it and insert the data.

so the basic steps

Open your my.ini file

and find, so put there the new created folder

"c:/my_folder/"

in double quotes

# Secure File Priv. 
secure-file-priv="C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/"

restart your server

place there your fff.txt

Which should look like this

test
test
test
test
test
test

and then run

LOAD DATA INFILE 'c:/my_folder/fff.txt' INTO TABLE fff
LINES TERMINATED BY '\r\n'; 

and sex rows are inserted.

1
  • @WilsonHauck The problem is solved for me. It was my bad. I did not notice that the name of the file was pet.txt.txt instead of pet.txt. – JConstantine Sep 30 '20 at 7:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.