0

I'm trying to use the first answer here to transfer a local postgre db to elephantSQL

https://stackoverflow.com/questions/1237725/copying-postgresql-database-to-another-server

The command given is: pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname

I have no chance to enter a password in the following:

owner@G700:~$ pg_dump -C -h localhost -U rep1 repdb1 | psql -h baasu.db.elephantsql.com -U bgpacbpe bgpacbpe
Password: 
Password for user bgpacbpe: pg_dump: [archiver (db)] connection to database "repdb1" failed: fe_sendauth: no password supplied

How can I resolve this?

If there is a less error prone way to do this I would also like to try that.

owner@G700:~$ psql --version
psql (PostgreSQL) 10.6 (Ubuntu 10.6-0ubuntu0.18.04.1)
asked Feb 24, 2019 at 21:19

1 Answer 1

1

Having two programs in the same pipeline both trying to prompt for a password at the same time is confusing your terminal.

There may be a shell-specific way to fix this, but I'd fix it at the PostgreSQL level by either changing the local server to use an authentication method that doesn't need a password, or making a .pgpass file to accommodate the local connection (and maybe the remote connection, too).

For what it is worth, a shell way to get around this would be:

pg_dump -C -h localhost ... | (sleep 10; psql -h ...)

Where the sleep gives you enough time to enter the local password.

answered Feb 24, 2019 at 21:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.