-3

Using the following command:

% pg_dump -h postgres.cs.host.ca -p 5433 -n _cscf_subscription -Fc -f ~/old.dump odyssey_prod
Password: 
pg_dump: [archiver (db)] connection to database "cs-rsub" failed: FATAL:  password authentication failed for user "cs-rsub"
FATAL:  password authentication failed for user "cs-rsub"

Yet psql works fine:

% psql -U _cscf_subscription -d odyssey_prod -h postgres.cs.host.ca -p 5433
psql (9.3.4, server 9.2.4)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

postgres=> \q

It is odd that pg_dump does not simply use the .pgpass file like psql does, however even pasting and manually typing in the password that is stored in the .pgpass file into the pg_dump password prompt still fails to authenticate. I an using the same account, same role, and same host.

What could be going wrong here?

In case the versions matter at all:

SELECT version(); executed via the working psql returns:

PostgreSQL 9.2.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit

And pg_dump --version is:

pg_dump (PostgreSQL) 9.3.4

I doubt this would matter but psql --version is:

psql (PostgreSQL) 9.3.4

Any ideas to what is going wrong?

ComputerLocus
  • 193
  • 4
  • 12

1 Answers1

4

You are not "using the same account, same role, and same host", not even close.

In your pg_dump call you don't supply any username (-U) or database (-d), only a hostname (-h) and schema (-n). So pg_dump uses your system user as a DB username and database to connect to. Judging by the error message, your system user seems to be "cs-rsub".

In the psql call you supply both a username (-U) and a database (-d) and neither is "cs-rsub".

Milen A. Radev
  • 962
  • 5
  • 17