0

I am trying to use pg_dump command in a container without entering the password.

I firstly checked pg_dump with password entered in promp, when I do

pg_dump -Fp --host my_hostname --port 32045 --dbname dbdev --username pgsqladmin test.sql 

it ask me the password. I enter it and it works.

When I try:

pg_dump -Fp --host my_hostnae --port 32045 --dbname dbdev --username pgsqladmin -w test.sql

I have the error:

pg_dump: error: connexion to database « dbdev » failed : fe_sendauth: no password supplied

I am working with PGAAS. What modifications can I do in order to avoid this error?

I use .pgpass file and I set ENV PGPASSFILE=/opt/nifi/.pgpass

.pgpass file has chmod 0600 And it looks like : hostname:port:database:username:password

LJRB
  • 199
  • 2
  • 11
  • 1
    I don't know what '/opt/nifi' is, seems like a weird name for your home directory. But '.pgpass' has two 's' in it, not one. – jjanes Mar 09 '23 at 18:06
  • 1
    Either the contents of the password file are wrong, or the permissions on that file. But you didn't tell us how either is configured. – Laurenz Albe Mar 10 '23 at 02:56
  • It's a mistake in my post, it is well .pgass name. I work with a container having Apache Nifi ETL and postgresql client in the same container. I built a dockerfile where workdir is opt/nifi/nifi-current/ – LJRB Mar 10 '23 at 08:07

1 Answers1

1

I believe this was answered here?

How to pass in password to pg_dump?

Make sure your file is .pgpass and not .pgpas and that it is chmod to 600

  • The name is well .pgpass, and I gave chmod 0600 to this file – LJRB Mar 10 '23 at 08:10
  • 1
    If you look in the link in the answer you could check to see if PGPASSWORD works for you. If that is the case, then it could easily be a typo or malformed character in your .pgpass file. – Troy Meyerink Mar 13 '23 at 16:25
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 16 '23 at 20:17
  • Hello, @TroyMeyerink I am able to do PGPASSWORD="mypass" pg_dump -U pgsqladmin -h hostname -d database -p 32045 -f test.sql and with ls in terminal I see the dump. But when I do : pg_dump -U pgsqladmin -h hostname -d database -p 32045 -w -f test.sql I have the error no password supplied – LJRB Mar 29 '23 at 08:38