Re: How to create a read only user account to access to all pg database?

From: Ville Rantamaula <ville(dot)rantamaula(at)gmail(dot)com>
To: KhunSanAung(dot)GIS(at)gmail(dot)com
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How to create a read only user account to access to all pg database?
Date: 2015-11-25 06:29:24
Message-ID: CAGf-6h--c9MPfsGr85MEVqguEK2QMUicCgxSgSqHGL02BDROVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

Assuming you have only the public schema in use per database (usually the
case). In each database run the following SQL:
CREATE ROLE backup WITH LOGIN;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO backup;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO backup;

After that, adjust the file PostgreSQL configuration file pg_hba.conf to
allow appropriate access for newly create ROLE backup.

Yours,
Ville

2015-11-25 5:35 GMT+02:00 KhunSanAung <khunsanaung(dot)gis(at)gmail(dot)com>:

> Hi All,
>
> I have several pg database with their own login user account.
> For backup purpose, I'd like to create an additional read only user
> account that can access all the pg database.
> How can I do it?
> Via PSQL command or via pgAdmin III client would be okay.
>
> Your help is high appreciated.
>
> Many thanks & best regards
>
> --
> Have a nice day!
> --
>
> *Mr. Khun San Aung*
> * <http://geoportal.icimod.org/>*
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Albe Laurenz 2015-11-25 08:37:03 Re: function nvl(numeric, integer) does not exist
Previous Message Shreeyansh Dba 2015-11-25 06:14:55 Re: How to create a read only user account to access to all pg database?