Обсуждение: Nu-B here

Поиск
Список
Период
Сортировка

Nu-B here

От
Amn Ojee Uw
Дата:

After this command 'sudo -u postgres psql'
I get this message :
could not change directory to "/home/my_account": Permission denied
psql (12.15 (Debian 12.15-1.pgdg120+1))
Type "help" for help.

I tried using help, but to no avail.
What am I doing wrong?

Thanks in advance!

Re: Nu-B here

От
Tom Lane
Дата:
Amn Ojee Uw <amnojeeuw@gmail.com> writes:
> After this command 'sudo -u postgres psql'
> I get this message :
> *could not change directory to "/home/my_account": Permission denied**
> **psql (12.15 (Debian 12.15-1.pgdg120+1))**
> **Type "help" for help.*

This is normal if you launch psql via "sudo -u postgres" in a directory
that the postgres user doesn't have permissions to read/chdir to.
psql will still start, but its working directory will not be what
you'd expect, so commands that involve local filesystem access might
misbehave.

We have a fix for this error report in the upcoming v16, but psql commands
that involve local filesystem access will still not act very nicely if
psql can't read your directory.

            regards, tom lane



Re: Nu-B here

От
Maciek Sakrejda
Дата:
On Wed, Jul 19, 2023, 17:36 Amn Ojee Uw <amnojeeuw@gmail.com> wrote:

After this command 'sudo -u postgres psql'
I get this message :
could not change directory to "/home/my_account": Permission denied
psql (12.15 (Debian 12.15-1.pgdg120+1))
Type "help" for help.

I tried using help, but to no avail.
What am I doing wrong?

It looks like you're hitting a non-fatal error at some point during psql startup when you're running as the "postgres" user. It seems to be a permissions issue. Do you still get the error if you run

sudo -u postgres psql --no-psqlrc

?

You may also want to create a Postgres user (possibly a superuser) matching your operating system user if you have not already done so to avoid having to deal with sudo for connecting.

Thanks
Maciek


Re: Nu-B here

От
Alban Hertroys
Дата:
> On 20 Jul 2023, at 02:36, Amn Ojee Uw <amnojeeuw@gmail.com> wrote:
>
> After this command 'sudo -u postgres psql'
> I get this message :
> could not change directory to "/home/my_account": Permission denied

What’s the reason that you’re using the OS user postgres?

If you’re simply trying to connect to the database named postgres as database user postgres, you can instead use the
command'psql -U postgres postgres’. 

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.




Re: Nu-B here

От
Adrian Klaver
Дата:
On 7/19/23 23:32, Alban Hertroys wrote:
> 
>> On 20 Jul 2023, at 02:36, Amn Ojee Uw <amnojeeuw@gmail.com> wrote:
>>
>> After this command 'sudo -u postgres psql'
>> I get this message :
>> could not change directory to "/home/my_account": Permission denied
> 
> What’s the reason that you’re using the OS user postgres?

Because the Debian/Ubuntu packaging sets up pg_hba.conf to use peer auth 
for local connections and the only database user created is postgres.

See:

https://ubuntu.com/server/docs/databases-postgresql

for more information.

> 
> If you’re simply trying to connect to the database named postgres as database user postgres, you can instead use the
command'psql -U postgres postgres’.
 


> 
> Alban Hertroys
> --
> If you can't see the forest for the trees,
> cut the trees and you'll find there is no forest.
> 
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com




Re: Nu-B here

От
Amn Ojee Uw
Дата:

Please note the following :
psql (12.15 (Debian 12.15-1.pgdg120+1
Thanks in advance

On 7/20/23 10:41 a.m., Adrian Klaver wrote:
On 7/19/23 23:32, Alban Hertroys wrote:

On 20 Jul 2023, at 02:36, Amn Ojee Uw <amnojeeuw@gmail.com> wrote:

After this command 'sudo -u postgres psql'
I get this message :
could not change directory to "/home/my_account": Permission denied

What’s the reason that you’re using the OS user postgres?

Because the Debian/Ubuntu packaging sets up pg_hba.conf to use peer auth for local connections and the only database user created is postgres.

See:

https://ubuntu.com/server/docs/databases-postgresql

for more information.


If you’re simply trying to connect to the database named postgres as database user postgres, you can instead use the command 'psql -U postgres postgres’.



Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.