Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this MYSQL statement giving me an error?

mysql> LOAD DATA INFILE '/home/myuser/myproject/power/ids-ads.txt' INTO TABLE ids_ads  FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';

ERROR 29 (HY000): File '/home/myuser/myproject/power/ids-ads.txt' not found (Errcode: 13)

The file is there. I even pasted the path into the mysql console. The permissions are correct.

In fact, I even tested it on root user and root mysql.

-rw-r--r--   1 myuser myuser  15893 2010-12-26 20:56 ids-ads.txt
like image 288
TIMEX Avatar asked Dec 27 '10 21:12

TIMEX


People also ask

What is the MySQL error?

Lost connection to MySQL server If an error message like “Lost connection to MySQL server” appears while querying the database, it is certain that the error has occurred because of network connection issues.

How do I fix MySQL error 1062?

1062 - Duplicate Entry To solve this, Set the primary key column as AUTO_INCREMENT . And when you are trying to insert a new row, ignore the primary key column or insert NULL value to primary key.


2 Answers

Note that when you do LOAD DATA INFILE, MySQL is looking for that file on the server - not on your client machine.

If you want to use LOAD DATA INFILE to load a file that is on the client machine (and not the server machine), you must use LOAD DATA LOCAL INFILE.

http://dev.mysql.com/doc/refman/5.1/en/load-data.html

like image 93
TehShrike Avatar answered Sep 20 '22 05:09

TehShrike


From the MySQL manual:

For security reasons, when reading text files located on the server, the files
must either reside in the database directory or be readable by all. Also, to use
LOAD DATA INFILE on server files, you must have the FILE privilege. For non-LOCAL
load operations, if the secure_file_priv system variable is set to a nonempty
directory name, the file to be loaded must be located in that directory. 

http://dev.mysql.com/doc/refman/5.1/en/load-data.html

like image 40
Marc B Avatar answered Sep 20 '22 05:09

Marc B