0

So I have this code...

mysql_query("SELECT * INTO OUTFILE '/home/user/public_html/feed-processed/processed.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\r\\n' FROM tbl_name") or die ('QueryBACKUP failed: ' .mysql_error());

I get this error...

Can't create/write to file '/home/user/public_html/feed-processed/processed.csv' (Errcode: 13)

I've read that you need to give the mysql user FILE access, but I don't know which user mysql is running under (as i've been told it's different from the user your running commands under). Is there an easy way to tell and then update the permissions?

Thanks in advance for any help, you guys are always awesome!

SoWizardly
  • 387
  • 1
  • 6
  • 16

1 Answers1

-1

You must execute query under mysql root account

GRANT FILE ON *.* TO 'username'@'host'
Hello
  • 98
  • 6
  • I'm actually currently running it as root. I used your code; GRANT FILE ON *.* TO 'root'@'localhost' & tried again, but no change. – SoWizardly Jun 21 '13 at 09:56
  • Add mysql user to "user" group `useradd -G user mysql` – Hello Jun 21 '13 at 10:07
  • working on trying this now...I don't have root access via ssh yet. Should work it out in another minute or two. – SoWizardly Jun 21 '13 at 10:23
  • that doesn't seem to work it either says that the group doesn't exist or that the username already exists. – SoWizardly Jun 21 '13 at 11:21
  • This is a file permissions error. If the problem could be resolved with the command you suggest then the error message would be completely different. See: http://stackoverflow.com/questions/668618/query-output-to-a-file-gives-access-denied-error – Panais Dec 10 '15 at 10:29