Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two PostgreSQL servers:

server 1: server 2:

I want to connect to the database on server 2 from server 1. I do it like this:

SELECT dblink_connect('hostaddr= port=5432 dbname=mydb user=postgres password=mypasswd');

My question is that when I do such connect my password is send as plaintext or its somehow encrypted during the transmission to the server 2?

I use PostgreSQL 9.3 on Linuxx Mint 16 (server 1) and Xubuntu 13.10 (server 2).

share|improve this question

Basically, dblink uses a libpq-style connection info string.
Add sslmode=require to your connection string or a more restrictive setting to disallow unencrypted transfers. More details in the manual here.

I would also advice not to have the password in your SQL statement at all. SQL statements may get logged. Or backups are stored in an insecure location ... I use the password file .pgpass for dblink connections.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.