Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install PostgreSQL-contrib-9.3 on Mac OSX?

I'm trying to get PostgreSQL up and running on my MacOSX 10.9.4.

I successfully installed PostgreSQL itself using Homebrew by following the instructions listed here: https://www.codefellows.org/blog/how-to-install-postgresql. It's up and I can connect to it using the psql command.

However, when I try to create the postgis extension, it fails (see below). I understand I need to install postgresql-contrib-9.3.

$ psql -d mydb
psql (9.3.5)
Type "help" for help.

mydb=# CREATE EXTENSION postgis;
ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.3.5/share/postgresql/extension/postgis.control": No such file or directory

How can I install this postgresql-contrib-9.3 on Mac OSX? I don't have apt-get. The instructions I have seen are not at all clear how to install it. Can someone please advise?

like image 917
trex Avatar asked Aug 24 '14 01:08

trex


People also ask

What is the best way to install PostgreSQL on Mac?

Step by step guide to set up a local PostgreSQL on Mac using DBngin: Download DBngin from it's download page and install on your Mac just like any other Mac apps. Open DBngin and click on + new server button. Choose PostgreSQL from the driver list, choose your PostgreSQL version, and name you server.

What is PostgreSQL contrib?

The postgresql-contrib package includes extensions and additions that are distributed along with the PostgreSQL sources, but are not (yet) officially part of the PostgreSQL core. Documentation for the modules contained in this package can be found in /usr/share/doc/packages/postgresql/contrib.

How do you check postgres is installed or not in Mac?

psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres. log 2>&1 & if you want to check and start postgres in one go (handy for automation scripts).


2 Answers

I found the answer here: http://postgis.net/install:

$ brew install postgis
<SNIP SNIP>

$ psql -d mydb
psql (9.3.5)
Type "help" for help.

dbname=# CREATE EXTENSION postgis;
CREATE EXTENSION
like image 131
trex Avatar answered Sep 30 '22 06:09

trex


On postgresql 9.4 contrib seems to be a part of the default installation. I was able to install cube and earthdistance like

PGUSER=postgres psql my-db
create extension cube;
create extension earthdistance;

from a default macports postgresql94-server installation.

like image 43
kometen Avatar answered Sep 30 '22 07:09

kometen