/o myfile - Permission Denied

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike kaplan

    /o myfile - Permission Denied

    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:

    Code:
    > sudo su postgres
    then

    Code:
    > psql
    then entering my database:

    Code:
    > \c mydb
    Now, I do my query as follows (example):

    Code:
    > 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:

    Code:
    > 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!
    Last edited by Frinavale; Oct 6 '10, 06:02 PM. Reason: Removed frustration from the question
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Does postgresql have write permissions for these directories?

    Comment

    • mike kaplan

      #3
      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.

      Comment

      • mike kaplan

        #4
        Hi again,

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

        Code:
        postgres=# grant all privileges on database mydb to mike;
        and I got the response:

        GRANT

        then i connected to the database

        Code:
        postgres=# /c mydb
        tried to do my query again, but still got the same error:

        dboutput: Permission denied


        Thanks again for your help
        Last edited by MMcCarthy; Oct 6 '10, 08:03 PM. Reason: added code tags

        Comment

        • rski
          Recognized Expert Contributor
          • Dec 2006
          • 700

          #5
          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)
          Code:
          echo 1 > /home/me/Desktop/myfile.out

          Comment

          • mike kaplan

            #6
            Hi rski,

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

            thanks again for your help

            Comment

            • rski
              Recognized Expert Contributor
              • Dec 2006
              • 700

              #7
              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?

              Comment

              Working...