Thread: Running postgres with a different user/group

Running postgres with a different user/group

From
Gabriele Bulfon
Date:
Hi,
I installed latest postgres from sources inside a custom environment of mine.
This environment runs various services, all under a common user/group.
I need to run postgres under the same user/group, witout having to create and use postgres user.
I could do it, and postgres starts.
But now I can't seem to connect to the database, because it says:

FATAL: role "postgres" does not exist

How can I let postgres run under my own user instead of postgres?
I can rebuild from sources, if needed.

Thanx,
Gabriele.

-= Mail sent through WebTop2 =-

Re: Running postgres with a different user/group

From
Raymond O'Donnell
Date:
On 03/11/2010 10:29, Gabriele Bulfon wrote:
> Hi,
> I installed latest postgres from sources inside a custom environment of
> mine.
> This environment runs various services, all under a common user/group.
> I need to run postgres under the same user/group, witout having to
> create and use postgres user.
> I could do it, and postgres starts.
> But now I can't seem to connect to the database, because it says:
>
> FATAL: role "postgres" does not exist
>
> How can I let postgres run under my own user instead of postgres?
> I can rebuild from sources, if needed.

Roles, or database users, are nothing whatever to do with operating
system users. The error you're getting is that the role under which
you're trying to connect doesn't exist within the PostgreSQL cluster.

Just specify the role when you're connecting - e.g., if using psql, do
something like this:

   psql -U <role> <database>

HTH,

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

Re: Running postgres with a different user/group

From
Gabriele Bartolini
Date:
Hi Gabriele,

On Wed, 3 Nov 2010 11:29:25 +0100 (CET), Gabriele Bulfon
<gbulfon@sonicle.com> wrote:
> I need to run postgres under the same user/group, witout having to
create
> and use postgres user.

That's reasonable and perfectly doable with Postgres.

> But now I can't seem to connect to the database, because it says:
> FATAL:  role "postgres" does not exist
> How can I let postgres run under my own user instead of postgres?

That means that PostgreSQL is successfully running. Try and connect to the
database using a different user by passing the '-U' option to psql or by
setting the PGUSER environment variable.

> I can rebuild from sources, if needed.

I believe there is no need to do that.

Ciao,
Gabriele
--
 Gabriele Bartolini - 2ndQuadrant Italia
 PostgreSQL Training, Services and Support
 Gabriele.Bartolini@2ndQuadrant.it - www.2ndQuadrant.it

Re: Running postgres with a different user/group

From
Gabriele Bartolini
Date:
Hi Gabriele,

   I forgot to mention one thing.

> That means that PostgreSQL is successfully running. Try and connect to
the
> database using a different user by passing the '-U' option to psql or by
> setting the PGUSER environment variable.

PostgreSQL creates a role/user inside the cluster with the same name as
the user that ran initdb.

Try and connect to either the postgres or the template1 database, by
executing:

psql template1

or

psql postgres

and then type:

\du

This will give you a list of the roles (users) inside the database.

Please make sure you specify the right port and host (or Unix socket) to
psql.

Ciao,
Gabriele

--
 Gabriele Bartolini - 2ndQuadrant Italia
 PostgreSQL Training, Services and Support
 Gabriele.Bartolini@2ndQuadrant.it - www.2ndQuadrant.it

Re: Running postgres with a different user/group

From
Gabriele Bulfon
Date:
Thanx guys, all of your solutions are fine, but I could manage it in a different manner.
Modified the ident map file to map my special system user to postgres, so I don't have to
specify the postgres user any more ;)

Thanx!
Gabriele.

-= Mail sent through WebTop2 =-



----------------------------------------------------------------------------------

Da: Gabriele Bartolini <Gabriele.Bartolini@2ndQuadrant.it>
A: Gabriele Bartolini <Gabriele.Bartolini@2ndQuadrant.it>
Cc: Gabriele Bulfon <gbulfon@sonicle.com> pgsql-general@postgresql.org
Data: 3 novembre 2010 12.26.04 CET
Oggetto: Re: [GENERAL] Running postgres with a different user/group

Hi Gabriele,

I forgot to mention one thing.

> That means that PostgreSQL is successfully running. Try and connect to
the
> database using a different user by passing the '-U' option to psql or by
> setting the PGUSER environment variable.

PostgreSQL creates a role/user inside the cluster with the same name as
the user that ran initdb.

Try and connect to either the postgres or the template1 database, by
executing:

psql template1

or

psql postgres

and then type:

\du

This will give you a list of the roles (users) inside the database.

Please make sure you specify the right port and host (or Unix socket) to
psql.

Ciao,
Gabriele

--
Gabriele Bartolini - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
Gabriele.Bartolini@2ndQuadrant.it - www.2ndQuadrant.it



Re: Running postgres with a different user/group

From
Raymond O'Donnell
Date:
On 03/11/2010 11:43, Gabriele Bulfon wrote:
> Thanx guys, all of your solutions are fine, but I could manage it in a
> different manner.
> Modified the ident map file to map my special system user to postgres,
> so I don't have to
> specify the postgres user any more ;)

Good stuff! Glad you got it to work.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie