Rispondi al commento

PostgreSQL 8.3 root login as postgres

Versione stampabileVersione stampabile
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'.

Rispondi

  • Indirizzi web o e-mail vengono trasformati in link automaticamente
  • Elementi HTML permessi: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Linee e paragrafi vanno a capo automaticamente.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Links to HTML content with 'rel="lightframe"' in the <a> tag will appear in a Lightbox when clicked on.

Maggiori informazioni sulle opzioni di formattazione.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

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!

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