0
mysql> LOAD DATA INFILE '/abc.txt' INTO TABLE test1 FIELDS TERMINATED BY '|';
ERROR 13 (HY000): Can't get stat of '/abc.txt' (Errcode: 2)

I used LOAD DATA as per the syntax. But getting the above error. can anybody tell what is the error..!? I tried searching google dev.mysql can't find what error it is??

Thanks in advance

5
  • can you show us the "stat /abc.txt" output. possibly related to file permissions error. lists.mysql.com/mysql/206087 Commented Dec 26, 2012 at 9:35
  • On which machine does it exist, server or client? Commented Dec 26, 2012 at 10:26
  • I m using localhost on client and server on same machine Commented Dec 26, 2012 at 10:27
  • above one is the output when I used stat abc.txt Commented Dec 26, 2012 at 10:31
  • Does the mysqld process have permission to access the file? Commented Dec 26, 2012 at 10:54

2 Answers 2

5

If the file is on your MYSQL server try using the full path.

LOAD DATA INFILE '/var/tmp/abc.txt' INTO TABLE test1 FIELDS TERMINATED BY '|';

If the file isn't on the server and it is on your local machine, and your user has access to SCP files between the servers ( try this

scp abc.txt mysqlserver: 

) then you should be able to do this (using full path again) ..

LOAD DATA LOCAL INFILE '/var/tmp/abc.txt' INTO TABLE test1 FIELDS TERMINATED BY '|';

If that doesn't work.. try renaming the file to test1.txt and using the 'mysqlimport' command?

Sign up to request clarification or add additional context in comments.

1 Comment

That was the clue I was seeking. On EC2, copying the file from user directory (/home/me/mydata/mydata.csv) to /var/tmp/mydata.csv worked
0

Login to the mysql console using the following flag:

mysql -uroot -p --local-infile

and then enter the password.

After that execute the load data command as follows:

LOAD DATA LOCAL INFILE '/abc.txt' INTO TABLE test1 FIELDS TERMINATED BY '|';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.