Connecting to PostgreSQL

Once you've installed, the question is usally, "How do I connect to Postgres?" On OSX, BigSQL includes 2 ways to connect interactively - the default command line (psql) or the desktop app pgAdmin III LTS

Using psql

The most frequent way of accessing Postgres is using the psql command line interactive shell. Psql is always installed with Postgres by BigSQL and makes it easy to develop and maintain databases.

On OSX, a short-cut to psql is added to Launchpad so you can quickly open a psql window.

Clicking the psql app will open a new terminal window with psql connected to the initial PostgreSQL database.

From a terminal window

If you want to launch psql from the command line, we provide an environment file that makes it easy to set your PG environment variables. Source this file and run psql.

$ cd ~/PostgreSQL/pg95/
$ . ./pg95.env
$ psql

You can tell you're connected to the recently installed version:

psql (9.5.1)
Type "help" for help.


Using pgAdmin III

pgAdmin is a popular graphical desktop app available on OS X and Windows that supports all Postgres development and administration tasks. PG Admin can be optionally installed when running the PostgreSQL installer for OSX or added using the PGC update manager.

1. Open Launchpad or the PostgreSQL folder under Applications. Click the icon for pgAdmin III

2. Click the plug icon to create a new server connection.

3. Create a name for this server connection. Enter "localhost" as the host name. Enter the port that you specified during your install, by default this is 5432. Enter the name of the superuser "postgres" and the password you created during installation. You will first connect to the default database, also named "postgres". Click "ok".

4. Expand headings to view the contents of the object browser. Here you will be able to preview all of the objects in your database.

5. Click on the magnifying glass icon to execute SQL queries.

6. Type in: SELECT * FROM information_schema.tables;

To see the names of the tables that exist in your database. Click the play button to execute query.

7. The results of this query will show in the Data Output tab of the Output Pane.