Thread: COPY ... FROM Permission denied ...

COPY ... FROM Permission denied ...

From
Pedro Doria Meunier
Date:
Hi All,

This is a bit embarassing ... but ...

I have a partial set of data that I want to restore via COPY ... FROM command

I have created a public folder for the effect and chown'ed both the folder and
the file to be fed into COPY to a+rw ...

I switched users with su - postgres and connected to the DB with the psql
command

All I'm getting is a Permission denied upon issuing the COPY command from
within psql interactive terminal! :O

So:
a) The Christmas *spirits* killed a billion of my brain cells
b) I need to go to postgresql kindergarden
c) I'm missing something very basic

Could someone please lend a hand?

Thanks in advance,

Pedro Doria Meunier
GSM: +351961720188
Skype: pdoriam


Attachment

Re: COPY ... FROM Permission denied ...

From
"Scott Marlowe"
Date:
On Tue, Jan 6, 2009 at 11:41 AM, Pedro Doria Meunier
<pdoria@netmadeira.com> wrote:
> Hi All,
>
> This is a bit embarassing ... but ...
>
> I have a partial set of data that I want to restore via COPY ... FROM command
>
> I have created a public folder for the effect and chown'ed both the folder and
> the file to be fed into COPY to a+rw ...
>
> I switched users with su - postgres and connected to the DB with the psql
> command
>
> All I'm getting is a Permission denied upon issuing the COPY command from
> within psql interactive terminal! :O

What is the exact error you're getting?

It's better to usually use copy from stdin which has none of these
problems.  It's the same syntax tat pg_dump uses when it creates a
backup.

For example:

COPY b (a_i, b) FROM stdin;
1    moreabc
\.

Re: COPY ... FROM Permission denied ...

From
Tom Lane
Date:
Pedro Doria Meunier <pdoria@netmadeira.com> writes:
> All I'm getting is a Permission denied upon issuing the COPY command from
> within psql interactive terminal!

Since you didn't show what you did or what the error was, we're just
guessing ... but I'm going to guess that you should use \copy not COPY.
The server normally can't read files in your home directory.

            regards, tom lane

Re: COPY ... FROM Permission denied ...

From
Pedro Doria Meunier
Date:
Hi Scott

Txs for replying.

Anyway I've found the problem (silly me... (blush) )
It had to do (of course) with the "forest" perms in the folder tree ...
As soon as I moved the file into the data/ folder and executed the COPY ...
FROM feeding it the file from that location everything worked as expected. :]

Thanks again.

Pedro Doria Meunier
GSM: +351961720188
Skype: pdoriam

On Tuesday 06 January 2009 06:48:47 pm Scott Marlowe wrote:
> On Tue, Jan 6, 2009 at 11:41 AM, Pedro Doria Meunier
>
> <pdoria@netmadeira.com> wrote:
> > Hi All,
> >
> > This is a bit embarassing ... but ...
> >
> > I have a partial set of data that I want to restore via COPY ... FROM
> > command
> >
> > I have created a public folder for the effect and chown'ed both the
> > folder and the file to be fed into COPY to a+rw ...
> >
> > I switched users with su - postgres and connected to the DB with the psql
> > command
> >
> > All I'm getting is a Permission denied upon issuing the COPY command from
> > within psql interactive terminal! :O
>
> What is the exact error you're getting?
>
> It's better to usually use copy from stdin which has none of these
> problems.  It's the same syntax tat pg_dump uses when it creates a
> backup.
>
> For example:
>
> COPY b (a_i, b) FROM stdin;
> 1    moreabc
> \.



Attachment

Re: COPY ... FROM Permission denied ...

From
Craig Ringer
Date:
Pedro Doria Meunier wrote:

> I have created a public folder for the effect and chown'ed both the folder and
> the file to be fed into COPY to a+rw ...

The server user (usually via the "group" or "other" permissions blocks)
must also have at least execute ('x') permissions on every directory
between the root directory (/) and the directory containing the files of
interest.

> All I'm getting is a Permission denied upon issuing the COPY command from
> within psql interactive terminal! :O

Do you have SELinux on your system? It may be denying the server access
even though the plain UNIX permissions would otherwise allow it, because
the server normally has no good reason to be accessing files from
wherever you've put them.

--
Craig Ringer