PostgreSQL Connecting to a Database

From NovaOrdis Knowledge Base
Revision as of 18:28, 4 December 2018 by Ovidiu (talk | contribs) (→‎Examples)
Jump to navigation Jump to search

Internal

Connect

Connect to a database.

Options

-h|--host=

-U|--username=

-d|--dbname=

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>