简体   繁体   中英

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?

Yes, you can use environment variables PGHOST and PGPORT.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM