By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

/o myfile - Permission Denied

P: n/a
I have no idea why this isn't working.
I'm trying to direct all output from my query to a file.
I entered postgres by typing in:

Expand|Select|Wrap|Line Numbers
  1. > sudo su postgres
then

Expand|Select|Wrap|Line Numbers
  1. > psql
then entering my database:

Expand|Select|Wrap|Line Numbers
  1. > \c mydb
Now, I do my query as follows (example):

Expand|Select|Wrap|Line Numbers
  1. > select * from table \o myfile.out
And i get the error:
myfile.out: Permission Denied.
I've tried inputting a whole path as well, like this:

Expand|Select|Wrap|Line Numbers
  1. > select * from table \o /home/me/Desktop/myfile.out
But I still get the same problem!
I've tried \g as well, same problem.

Please help!
Oct 6 '10 #1
Share this Question
Share on Google+
6 Replies


Expert 100+
P: 700
Does postgresql have write permissions for these directories?
Oct 6 '10 #2

P: n/a
Hi rski,

Thanks for your response. To tell you the truth, i'm not completely sure. Could you please tell me how to check this and give postgresql write permission? I thought that since i was running it as sudo I wouldnt have to worry about this.

Thanks again.
Oct 6 '10 #3

P: n/a
Hi again,

Okay, so I did some searching and found this line which I executed:

Expand|Select|Wrap|Line Numbers
  1. postgres=# grant all privileges on database mydb to mike;
and I got the response:

GRANT

then i connected to the database

Expand|Select|Wrap|Line Numbers
  1. postgres=# /c mydb
tried to do my query again, but still got the same error:

dboutput: Permission denied


Thanks again for your help
Oct 6 '10 #4

Expert 100+
P: 700
But I was talking about premissions to system directories and files.
Can postgres write to that file /home/me/Desktop/myfile.out and succesfully execute a command (not from database but from system command line)
Expand|Select|Wrap|Line Numbers
  1. echo 1 > /home/me/Desktop/myfile.out
  2.  
Oct 6 '10 #5

P: n/a
Hi rski,

I can execute this command successfully, however still no luck in postgres.........

thanks again for your help
Oct 7 '10 #6

Expert 100+
P: 700
You mean postgres execute succsesfully this command 'echo > ... '? I guess postgres server is running with postgres user rights, isn't it? Does user postgres start server?

Can postgres write to any other directory from database with /o option, like for example to /tmp/ directory?
Nov 14 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.