PostgreSQL 8.3 root login as postgres

Printer-friendly versionPrinter-friendly version
PostgreSQL Logo

I am writing some backup scripts for a server, and I needed a way to let the root user on the machine to login to PostgreSQL as 'postgres' user to perform some administrative operations.

To do so, I had to make a few changes to the configuration file, to let the root user to authenticate via local-socket without providing a password (the script is launched automatically by cron, no user interaction needed).

/etc/postgresql/8.3/main/pg_hba.conf

1
2
3
4
5
# TYPE  DATABASE    USER        CIDR-ADDRESS    METHOD
local           all             postgres                                        ident rootaspg
local           all             all                                             ident sameuser
host            all             all             127.0.0.1/32            md5
host            all             all             ::1/128                 md5

/etc/postgresql/8.3/main/pg_ident.conf

1
2
3
4
# MAPNAME     IDENT-USERNAME    PG-USERNAME
rootaspg                root                            postgres
rootaspg                root                            drupal
rootaspg                postgres                        postgres

This allows root to authenticate on postgresql via unix-socket as user 'postgres' or 'drupal'.

Who Am I?

~redShadow~ A.K.A. Samuele Santi is an Italian Open Source developer, currently working as a freelance developer, mainly in the web applications sector. Favourite programming languages: PHP and, of course, Python!

cocktails (1) bash (11) como lake rovers (1) doku (1) apt (1) blogroll (7) audio (1) camera mia (1) cryptography (1) caos (1) algorythms (1) 2v (1) C++ (2) e-mail (2) aircrack (1) documentation (2) alcool (1) 3d (3) archive (1) Drupal Forms (1) apache (1) debug (1) development (11) code (3) debian (1) aoe (1) cartoons (1) Drupal (21) arduino (1) awstats (3) contact manager (1) backup (3) cars (1) curl (1) blender (3) circuits (1) address book (2) dmcrypt (1) database (3) citroen (1)