Difference between revisions of "PostgreSQL Connect"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(-d|--dbname=)
(Connect as a Specific User to a Database)
 
(One intermediate revision by the same user not shown)
Line 14: Line 14:
  
 
Specifies the name of the [[PostgreSQL_Concepts#Database|database]] to connect to.
 
Specifies the name of the [[PostgreSQL_Concepts#Database|database]] to connect to.
 +
 +
==-p==
 +
 +
Specifies the port.
  
 
=Examples=
 
=Examples=
Line 38: Line 42:
  
 
  psql -U <''username''> <''dbname''>
 
  psql -U <''username''> <''dbname''>
 +
 +
==Connect to a PostgreSQL Instance Running in a Kubernetes Pod that Has Been Exposed as a NodePort Service==
 +
 +
psql -h localhost -p 5432 -U postgres

Latest revision as of 23:14, 13 August 2019

Internal

Connect

Connect to a database.

Options

-h|--host=

-U|--username=

-d|--dbname=

Specifies the name of the database to connect to.

-p

Specifies the port.

Examples

Connect Locally to the Default Database

psql postgres

This should work without any additional configuration.

Connect to a Remote Database

psql -h <host-name> -U <username> -d <database-name>
psql -h dev01.example.us-west-2.rds.amazonaws.com -U root -d dev01

If the database name is not specified, will connect to ...

Connect to the Default Database

psql -h localhost -U admin

Connect as a Specific User to a Database

psql -U <username> <dbname>

Connect to a PostgreSQL Instance Running in a Kubernetes Pod that Has Been Exposed as a NodePort Service

psql -h localhost -p 5432 -U postgres