Thread

  1. Nu-B here

    Amn Ojee Uw <amnojeeuw@gmail.com> — 2023-07-20T00:36:27Z

    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!
    
  2. Re: Nu-B here

    Tom Lane <tgl@sss.pgh.pa.us> — 2023-07-20T00:54:18Z

    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
    
    
    
    
  3. Re: Nu-B here

    Maciek Sakrejda <m.sakrejda@gmail.com> — 2023-07-20T00:55:49Z

    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
    
  4. Re: Nu-B here

    Alban Hertroys <haramrae@gmail.com> — 2023-07-20T06:32:36Z

    > 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.
    
    
    
    
    
  5. Re: Nu-B here

    Adrian Klaver <adrian.klaver@aklaver.com> — 2023-07-20T14:41:44Z

    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
    
    
    
    
    
  6. Re: Nu-B here

    Amn Ojee Uw <amnojeeuw@gmail.com> — 2023-07-25T22:10:24Z

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