Jason Cunread, Nov 17, 2011, 5:14:38 AM11/17/11 to I have a file that I'm grabbing by FTP via cron, then formatting via PHP. Then, also in PHP, I'm trying to import the formatted CSV file into that table. Here's the query that I'm using (I'm leaving it in PHP, just in case you see a problem with the escaping): $local_file = "/home/myacct/www/dir/file.csv"; $upload = "LOAD DATA INFILE \"$local_file\" "; $sth = mysql_query($upload); This script gives me the error of: Can't get stat of '[filename]' (Errcode: 13) I've been researching this error, and it seems like the most common explanation is a failed permission. But, I did give the user FILE permission, using (as root): GRANT FILE ON *.* TO [username]@localhost IDENTIFIED BY '[password]'; I also ensured that $local_file is chmod to 0755. Any suggestions? Joe Makowiecunread, Nov 17, 2011, 7:19:12 AM11/17/11 to
The Natural Philosopherunread, Nov 17, 2011, 7:30:57 AM11/17/11 to try running the command manually without php involved Its not clear what is going on here. Axel Schwenkeunread, Nov 17, 2011, 7:37:20 AM11/17/11 to Jason C <> wrote: > $local_file = "/home/myacct/www/dir/file.csv"; ... > This script gives me the error of: > I've been researching this error, and it seems like the most common > I also ensured that $local_file is chmod to 0755. ~ $perror 13 So obviously something is wrong with file permissions. It must be See http://dev.mysql.com/doc/refman/5.1/en/load-data.html XL Jason Cunread, Nov 17, 2011, 4:46:20 PM11/17/11 to On Thursday, November 17, 2011 7:30:57 AM UTC-5, The Natural Philosopher wrote: I did, but had the same error. I only posted it here in PHP in case you guys thought there was an escaping problem (because I spent about 20 minutes trying to figure one of those out, only to find that I needed to escape the \n). The query I'm pasting directly in to SSH is: LOAD DATA INFILE '/home/myacct/www/dir/file.csv' Jason Cunread, Nov 17, 2011, 4:40:49 PM11/17/11 to I had actually found that link before, too. I tried to use LOAD DATA LOCAL INFILE last night, but then quickly discovered that I have it disabled for security purposes (due to a strong suggestion from my firewall). I'm not sure what the security problem is with it, but is this something that should be re-enabled? Is there no other way to do what I need without it? Jason Cunread, Nov 17, 2011, 4:55:05 PM11/17/11 to On Thursday, November 17, 2011 7:37:20 AM UTC-5, Axel Schwenke wrote: By default, all of my public directories are created at 0755. I double checked, and yes, it's definitely world-readable. When I FTP to the file as root, though, I see that file.csv has an Owner/Group of root/root (where the PHP file is user/user). Could that be a problem? It's a live database, so I don't want to run the query again until late tonight, when the traffic is down. Unless you say otherwise, I'll try changing the O/G, and see if that helps. Axel Schwenkeunread, Nov 17, 2011, 5:40:14 PM11/17/11 to Jason C <> wrote: >> ~ $perror 13 > By default, all of my public directories are created at 0755. I The file is opened (or tried to) by the mysqld process which is The error message indicates an error at stat'ing the file. So mysqld Maybe you're running apparmour or similar? This could also explain XL Jason Cunread, Nov 18, 2011, 2:34:02 AM11/18/11 to For anyone following, I enabled LOCAL (go to /etc/my.cnf and remove the line that says "local-infile=0", then restart MySQL), and then using LOAD DATA LOCAL INFILE worked without error. This is apparently a security risk, but I haven't found any other way to load the file without it. I can import a file with phpMyAdmin, though, so I know it's possible... I just haven't found it. |