We configure the file .pgpass as follows in order to create database backups without entering a password:

-bash-4.2$ more .pgpass
-bash-4.2$ pwd
-bash-4.2$ whoami
-bash-4.2$ more .pgpass

But after that still pg_dump insists to enter the password - why?

Where am I wrong?

pg_dump -U  ambari  -f ambari.sql

You are trying to connect to a database called ambari this way (when specifying only the -U parameter, the DB name is taken from its value).

From the .pgpass file it looks you want to connect to the postgres DB. Specify -d postgres, too, or set


in your .pgpass file. (As it turns out, there is an ambari DB, so the connection parameters look all right.)

Note that by default this file has to be in the OS user's (in this case postgres) home directory. Alternatively, you can specify its location in other ways.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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