1

I try to use the command to migrate data between two PG servers, but both need password:

pg_dump -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname

Then I get the error:

pg_dump: [archiver (db)] connection to database "database" failed: FATAL:  password authentication failed for user "postgres"

Is there any option to solve the issue? I'm not sure how to specific the password in the command.

Frank
  • 83
  • 8

1 Answers1

1

Use a password file to store the passwords for both databases, then the PostgreSQL client will be able to connect to both without prompting for a password.

The password file would look like this:

localhost:5432:dbname:localuser:password1
remotehost:5432:dbname:remoteuser:password2
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263