The easiest way to get started with PostgreSQL on the Mac

CLI Tools

Configure your $PATH includes many command line tools. If you want to use them, you must configure the $PATH variable.

The easiest way to configure your PATH is to execute the following command:

sudo mkdir -p /etc/paths.d &&
echo /Applications/ | sudo tee /etc/paths.d/postgresapp

Don’t forget to close the Terminal window and open a new one for changes to take effect.

Of course, you could also just edit your .profile file instead.

Whatever method you use, you can check if the path is set up correctly by typing which psql.

Tools provided by

The following tools come with

  • PostgreSQL: clusterdb createdb createlang createuser dropdb droplang dropuser ecpg initdb oid2name pg_archivecleanup pg_basebackup pg_config pg_controldata pg_ctl pg_dump pg_dumpall pg_receivexlog pg_resetxlog pg_restore pg_standby pg_test_fsync pg_test_timing pg_upgrade pgbench postgres postmaster psql reindexdb vacuumdb vacuumlo
  • PROJ.4: cs2cs geod invgeod invproj nad2bin proj
  • GDAL: gdal_contour gdal_grid gdal_rasterize gdal_translate gdaladdo gdalbuildvrt gdaldem gdalenhance gdalinfo gdallocationinfo gdalmanage gdalserver gdalsrsinfo gdaltindex gdaltransform gdalwarp nearblack ogr2ogr ogrinfo ogrtindex testepsg
  • PostGIS: pgsql2shp raster2pgsql shp2pgsql

Man pages ships with man pages. If you’ve configured your PATH as described above, just type man psql to read the official docs.

System provided tools

psql is the PostgreSQL command-line interface to your database. Mac OS 10.7 and 10.8 ship with an older version of PostgreSQL, which can be started with the following command:

psql -h localhost