The Golden Spot

I hope this helps someone who is learning about Linux and web application programming with Python, Django, and Javascript.

Saturday, October 31, 2009

pg_dump fails:


$ pg_dump -o -U mydbuser mydb > backup.db.data

$ pg_dump: [archiver (db)] connection to database "mydb" failed: FATAL: password authentication failed for user "mydbuser"


My /var/lib/pgsql/data/pg_hba.conf :


# "local" is for Unix domain socket connections only
local all all ident sameuser
#
host all all 127.0.0.1/32 md5

I thought that since I am logged into the postmaster machine, I would be able to enter the mydbuser database password and execute the command.

According to:

http://www.postgresql.org/docs/8.1/interactive/app-pgdump.html

the option -h is the following:

-h host
--host=host

Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted.


Since I did not use -h flag in the command, pg_dump was using a Unix socket to connect the the database and therefore using the IDENT authentication option. I should could have said -h 127.0.0.1 in my pg_dump command- like so:


$ pg_dump -o -U mydbuser -h 127.0.0.1 mydb > backup.db.data


so that I could authenticate using the md5 database user password at the prompt.

Labels: ,

0 Comments:

Post a Comment

<< Home