Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT INTO OUTFILE can't write to file

I'm trying to do a SELECT INTO OUTFILE and I'm getting the following error:

General error: 1 Can't create/write to file '/home/jason/projects/mcif/web/downloads/dump.csv' (Errcode: 13). Failing Query: "
SELECT name
INTO OUTFILE '/home/jason/projects/mcif/web/downloads/dump.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
FROM account a

I know what the problem probably is: my downloads folder isn't writable by my MySQL user. I don't know how to solve this problem for two reasons:

  • I don't know how to find out what the MySQL user is
  • I don't know how to add the MySQL user to the users who are able to write to the downloads folder

I'm on Ubuntu Linux. Can someone help me get past those two things?

like image 320
Jason Swett Avatar asked Nov 22 '10 21:11

Jason Swett


2 Answers

write the file /tmp/dump.csv and the copy it over.. That will let you see who is running what. My guess is that you are doing this from the web and the client is running as the web server process...

like image 96
Doon Avatar answered Nov 15 '22 23:11

Doon


mysql -u USERNAME --password=PASSWORD --database=DATABASE --execute='SELECT FIELD, FIELD FROM TABLE LIMIT 0, 10000 ' -X > file.xml

like image 33
Navrattan Yadav Avatar answered Nov 15 '22 22:11

Navrattan Yadav