Postgres /root": Permission denied

5,790

There are three parts in the output:

  1. could not change directory to "/root": Permission denied: your 'sudo' succeeds but your postgres user fails to access the home of root. You may check for the setting of homedirectory for postgres in /etc/passwd.

  2. The files belonging to this database system will be owned by user "postgres". This user must also own the server process. : This is the normal permissions reminder from initdb. So you know initdb started regardles of failed directory change.

  3. initdb: invalid locale settings; check LANG and LC_* environment variables: here initdb fails for real due to missing locale settings.

I think You need to check your sudo configuration and make sure your postgres user has a proper environment before calling initdb.

Share:
5,790

Related videos on Youtube

dcalixto
Author by

dcalixto

Updated on September 18, 2022

Comments

  • dcalixto
    dcalixto over 1 year

    why on ubuntu 14.10 every time that i try to start the postgres on:

    sudo -p 'sudo password: ' -u postgres /usr/lib/postgresql/9.4/bin/initdb -D /mnt/postgresql/9.4/data
    

    show this:

    could not change directory to "/root": Permission denied The files belonging to this database system will be owned by user "postgres". This user must also own the server process.

    initdb: invalid locale settings; check LANG and LC_* environment variables

    • Craig Ringer
      Craig Ringer over 8 years
    • dcalixto
      dcalixto over 8 years
      yeah, another guy recommended to post this type of question here
    • Craig Ringer
      Craig Ringer over 8 years
      No problem. I'm just cross-linking so if someone finds one they can see there might be more info at the other.