Maciej
Maciej

Reputation: 10805

Postgresql - adding hostname / port to commandline

I have migrated from 9.6 to 12 and no longer using socket connection.

So now to execute pgsql commands (Linux command-line) I have to add two parameters:

-h 127.0.0.1 -p 5432 

All works well then. Problem is I have dozen of scripts on few environments so now I have to correct all of those.

I wonder if there is any setting / system variable I can set to instruct PostgreSQL to connect to local host / port - so I don't need to correct all of my scripts ?

Upvotes: 0

Views: 418

Answers (1)

pifor
pifor

Reputation: 7882

Yes, you can use environment variables PGHOST and PGPORT.

See https://www.postgresql.org/docs/current/libpq-envars.html

Upvotes: 1

Related Questions