How to install PostgreSQL 9.6 on Mac OS X (10.7 or later)

PostgreSQL is an open source relational database system that has been around for well over a decade and has proven to be a great all around storage choice when developing a web application.

In this guide we are going to walk through installing PostgreSQL 9.6 on Mac OS X (10.7 or later) so that we can eventually start using it with a Go application, but you can follow along with this guide to set up Postgres for use with pretty much anything, including Rails, Django, or Go.

Once we have Postgres setup we will also look at adding all of the executables to our path so that we can type things like psql in the terminal in order to access Postgres. It is important to note that this step IS NOT required to use postgres, but it is nice to have so I suggest doing it.


The first thing we want to do is install PostgreSQL using You can find that here: is about 50mb, and is by far the easiest way to setup Postgres on a Mac. It runs like any other you would download, can automatically start up with your Mac, and allows us to skip a lot of command line steps that used to be required to set up Postgres on a Mac. Yay for progress!

You can grab whatever version you need at the “Other versions” section of the page, but I will be using th emost recent version which currently uses PostgreSQL 9.6.0.

Once you have unzipped the download you will want to copy the Postgres app to your Applications folder and then open it. You might be asked if you want to open this application because it was downloaded from the internet. Click open.

You should now have Postgres running locally, and you should see a little elephant icon on the top right section of your menu bar. Click on it and then click the “Open psql” option.

Opening psql via the elephant icon.

If you don’t see any errors that means everything is working! Congrats!

Now lets go ahead and add Postgres to our path.

Enabling Postgres command line tools

If you are using the default terminal, you are going to want to modify the file at ~/.bash_profile. If you are using something like Oh My Zsh you are going to want to modify the file ~/.zshrc.

To edit this file you likely need to open it via the terminal, so open your terminal and type open ~/.bash_profile. You can replace the word open with subl or whatever text editor you prefer.

Once your zbash_profile or .zshrc file is open, add the following line to the end of the file:

export PATH=$PATH:/Applications/

After that you will need to quit and restart your terminal This is to make sure it reloads with the changes you just made.

Once you have restarted your terminal, try running psql.

psql -U postgres

You should get the following output.

psql (9.6.0)
Type "help" for help.


You have now successfully connected to Postgres using the postgres role. This role doesn’t require a password because Postgres is only accessible locally, so it is unlikely to present any security issues.

Up Next…

Now that you have PostgreSQL 9.6 installed you are ready to start using it! Check out the next article in this series to learn how to do that - Creating databases and tables with PostgreSQL.

You can also check out an overview of the entire series, along with links to each article in the series, by going here - .

Learn Web Development with Go!

Sign up for my mailing list and I'll send you a FREE sample from my course - Web Development with Go. The sample includes three chapters from the book, and over 2.5 hours of screencasts.

You will also receive notifications when I release new articles, along with other freebies that I only share with my mailing list.

Avatar of Jon Calhoun
Written by
Jon Calhoun

Jon Calhoun is a full stack web developer who also teaches about Go, web development, algorithms, and anything programming related. He also consults for other companies who have development needs. (If you need some development work done, get in touch!)

Jon is a co-founder of EasyPost, a shipping API that many fortune 500 companies use to power their shipping infrastructure, and prior to founding EasyPost he worked at google as a software engineer.

More in this series

This post is part of the series, Using PostgreSQL with Go.

Spread the word

Did you find this page helpful? Let others know about it!

Vote on Hacker News

Sharing helps me continue to create both free and premium Go resources.

Want to discuss the article?

See something that is wrong, think this article could be improved, or just want to say thanks? I'd love to hear what you have to say!

You can reach me via email or via twitter.

Recent Articles Mini-Series Tags About Me Go Courses

©2018 Jonathan Calhoun. All rights reserved.