0

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
  • 23
  • 6

1 Answers1

0

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
  • 167,868
  • 16
  • 137
  • 184