psql -h hostname -U username -d database
Options:
Option Description
-h <host> Hostname or IP address of the PostgreSQL server
-p <port> Port number (default is 5432)
-U <username> Username to connect as
-d <dbname> Database name
-W Prompt for password (useful if password auth is required)
-f <filename> Execute commands from a SQL script file
-c "<command>" Execute a single SQL command and exit
-v var=value Set psql variable (used inside scripts)
--set=var=value Same as -v, more explicit
--dbname=<connstr> Full connection string, e.g.: postgresql://user:pass@host:port/dbname
Example
psql -h pg01.oric.no -p 5432 -U myuser -d mydb
Alternatively, use an URL, which is more scripting friendly:
psql "postgresql://replicate@pg01.oric.no:5432/mydb"
No comments:
Post a Comment