Connecting to the PostgreSQL database with pgAdmin

There are a number of front-end tools available for connecting to, and working with, the PostgreSQL database. Among the most popular are psql, a command-line tool for querying the database, and the free and open source graphical tool pgAdmin.

Any data querying and manipulation you can do with pgAdmin can also be done at the command line with psql.

Note

This section uses the graphical utility pgAdmin which may not be automatically present, depending on the type of installation of OpenGeo Suite. Please see the Installation section for information on how to install these tools for your platform.

Launching pgAdmin

Depending on how OpenGeo Suite was installed pgAdmin may or may not have been installed. See the Installation section for installation instructions. Once installed follow the instructions below for your platform.

Windows

On Windows pgAdmin can be launched from the Start Menu.

../../_images/pgadmin_win.png

Launching pgAdmin on Windows

Mac OS X

On OS X, the pgAdmin application is accessible from the installer image under PostGIS Utilities.

../../_images/pgadmin_mac.png

Launching pgAdmin on OS X

Linux

The pgAdmin application is installed via the pgadmin3 package, and can be launched from the terminal with the pgadmin3 command. On systems with graphical interfaces, pgAdmin III may be available from the Applications menu.

Note

Some extra steps need to performed before pgAdmin will be available from both local and remote hosts. Please see the section on Connecting to PostgreSQL on Linux for the first time for configuration information.

Working with pgAdmin

Depending on how you installed OpenGeo Suite, you may already have one pre-configured PostGIS server, localhost:5432, listed in the pgAdmin Object browser.

../../_images/pgadmin_postgissrv.png

PostGIS server in pgAdmin

If you don’t have an entry for PostGIS listed, add a new server connection manually. Click File ‣ Add Server and complete the New Server Registation dialog box to register a new server. Ensure the Host is set to localhost and Port is 5432 (unless you have configured PostgreSQL for a different port).

../../_images/pgadmin_connectwindows.png

Connection parameters on Windows / OS X

../../_images/pgadmin_connectlinux.png

Connection parameters on Linux

To connect to the PostGIS server, double-click the PostGIS server item and provide the password when prompted.

To view the databases in this instance, expand the Databases item. Double-click one of the listed databases to reveal the contents in the Object browser.

../../_images/pgadmin_treetable.png

Navigating the database

When executing SQL queries, make sure you have the intended target database selected. The SQL Query dialog box will confirm the current database selection.

../../_images/pgadmin_querydb.png

Querying a database

Note

If you are just installing OpenGeo Suite for the first time, there will only be a generic “postgres” database installed, with no tables, and you will need to create a new spatial database.