postgresql: .pgpass not working
- Create .pgpass file with content
host:5432:somedb:someuser:somepass
- set the permissions
sudo chmod 600 .pgpass
- Set the file owner as the same user using which you logged in :
sudo chown login_username:login_username .pgpass
- Set PGPASSFILE environment variable :
export PGPASSFILE='/home/user/.pgpass'
Now check by connecting to database :
psql -h host -U someuser somedb
It did not prompt for a password, and logged-in to postgresql.
Although question has already been answered and accepted, it may also happen that permissions on .pgpass file are not properly set. It has to have the world and group access disallowed:
/bin/chmod 0600 ~/.pgpass
Did you try specifying the host, user, & db?
pg_dump -U someuser -h localhost somedb > directory/somefile.dump