7

I am setting up a POSTGRESQL on a UBUNTU 16.04 server:

I followed the explanation given here, I did: The install:

sudo apt-get install postgresql postgresql-contrib`

The setup of postgres user and password:

sudo -u postgres psql postgres
\password [postgres password]

At that point the command postgres worked.

Then before creating any SCHEMA, I followed up some guidelines to set up a new data directory for POSTGRES under /srv/datadisk01/database, datadisk01 being a harddrive meant to store and use the database.

I changed the owner of /srv/datadisk01/database to postgres user with chmod.

I launched: /usr/lib/postgresql/9.5/bin/initdb -D /srv/datadisk01/database, which worked.

Then I ran sudo service postgresql stop. I updated the file /etc/postgresql/9.5/main/postgresql.conf, changing

data_directory = ‘/var/lib/postgresql/9.5/main’

to

data_directory = ‘/srv/datadisk01/database’

And sudo service postgresql start.

I stopped there and switched to other topics settings not regarding POSTGRES.

Later on (and a reboot of the machine), command postgres fails and returns:

postgres: command not found

I can look how to re-configure the environment variable to make it work and I will, but I wonder if there is a reason that the command availability disappeared from the environment variable after the implementation of a custom data directory?

  • 1
    it seems like the actual command is psql or psql postgres and not postgres. Am I correct? – Yaron Mar 29 '17 at 7:54
  • yes you're right, i think i understand now, when I did -u postgres psql postgres it means launch psql postgres with user postgres and -u is used to define the user I guess (i am learning as I go with Ubuntu, so I am a bit fresh on things like that). – nyluje Mar 29 '17 at 7:59
10

postgres execution command is psql and not postgres

postgres is the username

info from pgGettingStarted

To test your connection using psql, run the following command:

psql -U postgres -W
| improve this answer | |
1

You can also try that

psql -U user_name -h 127.0.0.1 database_name

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.