Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INTO OUTFILE in SQL on MAC OSX - Errcode 13 "Permission denied"

I switched from being a long term windows user to mac.

Now I face this problem trying to save a query to a csv file:

mysql> SELECT * FROM mytable
-> INTO OUTFILE '/Users/localuser/Documents/myfolder/test.csv'
-> FIELDS TERMINATED BY ','
-> ENCLOSED BY '"'
-> LINES TERMINATED BY '\n';

But i get:

ERROR 1 (HY000): Can't create/write to file 
'/Users/localuser/Documents/myfolder/test.csv' (Errcode: 13 "Permission denied")

I think it is something about setting permission but i have not found a solution that works for my mac osx. thank you in advance.

Please take into account that this ones works MySQL writing on a text file

But what I am looking for is more the operation to set any directory so that *.csv files can be put there by the sql server.

like image 670
J. Bug Avatar asked Sep 13 '25 01:09

J. Bug


1 Answers

I meet the same problem, and I find that it is relevant to file permission of Mac OS, not relevant to MySQL.

The solution is to make all the folders in the path have permission of 755 (read and execution) and to make the folder putting the csv file has the permission of 777 which can write the file.

So in your case, the folders in '/Users/localuser/Documents' should have 755 permission and the folder 'myfolder' should have 777 permission.

like image 120
Neil Avatar answered Sep 15 '25 13:09

Neil