How to connect to PostgreSQL on Linux, VPS, VDS, Server for first time

If you are using or starting to use PostgreSQL and have installed it or are planning to install it then here is our tutorial on How to Install PostgreSQL on Linux CentOS 7 Server, VPS, VDS

But once you have a ready PostgreSQL server you would need to set up a password to project to your main root user and at the same to connect to it using a management tool.

A little reminder doesn't use this for your App connection since this is the main root user that has unlimited access and privileges to the PostgreSQL databases including users and data.

Setting a password for the postgres user

On Linux systems, there is no default password set.
To set the default password:

  1. Run the psql command from the postgres user account:
    sudo -u postgres psql postgres
  2. Set the password:
    \password postgres
  3. Enter a password.
  4. Close psql.
    \q