Skip to main content

Connecting to the Database

psql

Synopsis

psql [option...] [dbname [username]]
options:
-h, --host=HOSTNAME database server host (default “local socket”)
-p, --port=PORT database server port
-U, --user database username
-d, --dbname=DBNAME database name to connect to
-f, --filename=FILENAME execute commands from file
-?, --help show help

Example

./psql -h localhost -p 5432 -d bldb -U brytlyt

Will connect to the bldb database as the brytlyt database user via port 5432.

Description

psql is a terminal-based front-end to PostgreSQL that enables you to type in queries interactively, issue them to PostgreSQL, and see the query results. Alternatively, input can be from a file. In addition, it also provides meta-commands and various shell-like features to facilitate writing scripts and automating a wide variety of tasks.

See PostgreSQL documentation for more detail.

PgAdmin

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL. pgAdmin may be used on Linux, Unix, Mac OS X and Windows to manage PostgreSQL 9.2 and above.

Downloads are available in source and binary formats at the pgAdmin downloads site.