Re: Linux Users vs PostgreSQL Users - Mailing list pgsql-novice

From Alan Hodgson
Subject Re: Linux Users vs PostgreSQL Users
Date
Msg-id 2246101.YixKdnZjFQ@skynet.simkin.ca
Whole thread Raw
In response to Re: Linux Users vs PostgreSQL Users  (Michael Convey <smconvey@gmail.com>)
List pgsql-novice
On Tuesday, November 10, 2015 05:45:51 PM you wrote:
> ​Thanks Alan & Felipe. So, in the following line, what does the last
> "postgres" do and is it necessary?
>
> sudo -u postgres psql postgres
>
> Source: 1st answer at
> http://serverfault.com/questions/110154/whats-the-default-superuser-username
> -password-for-postgres-after-a-new-install
>
> Wouldn't this be the same?
>
> sudo -u postgres psql

The second postgres tells psql which database to connect to. There is by
default one named postgres. And yes it is redundant in this case, as I believe
psql tries to connect to a database named after the user you connect as, if
you don't otherwise specify the database name.

So in this case you have a system user called postgres, a PostgreSQL role
called postgres, and a default database called postgres, all coming into play,
which is probably a little confusing at first.

Attachment

pgsql-novice by date:

Previous
From: Michael Convey
Date:
Subject: Re: Linux Users vs PostgreSQL Users
Next
From: Alan Hodgson
Date:
Subject: Re: [pgsql-novice] Daily digest v1.3706 (6 messages)