Re: Linux file permission for COPY TO SQL command

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Krzysztof <kj(at)limes(dot)com(dot)pl>
Cc: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: Linux file permission for COPY TO SQL command
Date: 2025-10-29 19:55:53
Message-ID: 2892301.1761767753@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Krzysztof <kj(at)limes(dot)com(dot)pl> writes:
> Actually server and client are installed on the same machine.
> The file (real file) permissions are as follows:

> -rwxrwxrwx+ 1 kaj kaj 2 Oct 27 22:36 fd/fdo.txt

> The directory permissions are as follows:

> drwxrwxrwx+  4 kaj kaj     4096 Oct 27 22:36 fd

> The SQL command which tries to write to the file is this:

> copy (select key from xcg where add=false) to '/home/kaj/fd/fdo.txt';

The /home and /home/kaj directories would also need to be
world-searchable for the server to be able to write there.
(Do not make them world-writable...)

Did you notice the HINT that goes with that error message?

HINT: COPY TO instructs the PostgreSQL server process to write a file. You may want a client-side facility such as psql's \copy.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Roland Müller 2025-10-29 20:11:19 Re: Linux file permission for COPY TO SQL command
Previous Message Krzysztof 2025-10-29 18:44:01 Re: Linux file permission for COPY TO SQL command