2

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

-bash-4.2$ more .pgpass
localhost:5432:postgres:ambari:bigdata
-bash-4.2$ pwd
/var/lib/pgsql
-bash-4.2$ whoami
postgres
-bash-4.2$ more .pgpass
localhost:5432:postgres:ambari:bigdata
-bash-4.2$

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

Where am I wrong?

pg_dump -U  ambari  -f ambari.sql
Password:
3

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

localhost:5432:*:ambari:bigdata

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.