Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

DB: Postgres 9.0 Client: Windows 7 Server Windows 2008, 64bit

I'm trying to connect remotely to a postgres instance for purposes of performing a pg_dump to my local machine.

Everything works from my client machine, except that I need to provide a password at the password prompt, and I'd ultimately like to batch this with a script.

I've followed the instructions here:

http://www.postgresql.org/docs/current/static/libpq-pgpass.html

but it's not working.

To recap, I've created a file on the client (and tried the server as well): C:/Users/postgres/AppData/postgresql/pgpass.conf, where postgresql is the db user.

The file has one line with the following data:

*:5432:*postgres:[mypassword]

(also tried explicit ip/dbname values, all asterisks, and every combination in between.

(I've also tried replacing each '*' with [localhost|myip] and [mydatabasename] respectively.

From my client machine, I connect using:

pg_dump -h [myip] -U postgres -w [mydbname] > [mylocaldumpfile]

I'm presuming that I need to provide the '-w' switch in order to ignore password prompt, at which point it should look in the AppData directory on the server.

It just comes back with "connection to database failed: fe_sendauth: no password supplied.

Any insights are appreciated.

As a hack workaround, if there was a way I could tell the windows batch file on my client machine to inject the password at the postgres prompt, that would work as well.

Thanks.

share|improve this question
    
*:5432:*postgres:[mypassword] .... don't you mean *:5432:*:postgres:[mypassword] ? Note the colon separating the username and the previous wildcard. –  Craig Ringer Nov 6 '13 at 12:42
    
To confirm, are you running the pg_dump command as the 'postgres' user? Also, have you tried hardcoding the PGPASSFILE environment variable to that path? –  alienth Dec 23 at 8:29

1 Answer 1

I would try the equivalent of strace to see whether and where it looks for pgpass.conf and what it does with it.

The -w option is unnecessary and unrelated to your problem.

share|improve this answer
    
The equivalent of strace is Sysinternals Process Monitor. It's quite handy. technet.microsoft.com/en-au/sysinternals/bb896645.aspx –  Craig Ringer Nov 6 '13 at 12:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.