So, you want to install PostgreSQL and PostGIS on Mac OS X Lion? Good idea. Here’s how to do it.
Start by downloading and installing MacPorts from www.macports.org.
Install PostgreSQL:
$ sudo port install postgres90 postgres90-server
And follow the installation instructions. If you get a permission denied error, you can try running it using sudo -u postgres before the command itself. If you get an error message saying “Is the server running locally and accepting connections on Unix domain socket xxx?” try running it with -h localhost. This is an issue that started on Mac OS X Lion.
If you want to install a default user that will be used to login to your PostgreSQL using psql:
$ createuser -h localhost -U postgres -s <your OS X username>
E.g.
$ createuser -h localhost -U postgres -s admin
Next, create a database for development. We will be using this database later on when installing PostGIS:
$ createdb -h localhost my_development_database
Install PostGIS:
$ sudo port install postgis
Install PostGIS in the database:
$ cd /opt/local/share/postgresql90/contrib/postgis-1.5/ $ psql -d my_development_database -f postgis.sql -h localhost $ psql -d my_development_database -f spatial_ref_sys.sql -h localhost
And you’re done! You can now use PostGIS in your my_development_database database.
Related posts
Tags: Geospatial, OS X, PostGIS, PostgreSQL
[...] We will first create our geospatially enabled database. First check out out my post on installing PostgreSQL and PostGIS on Mac OS X. [...]
PostgreSQL 9.0 comes pre-installed on MacosX Lion,
and is most likely already running when the macPorts version above gets installed.
Okay – Thanks for the info, Adrian.
/Lasse
Postgres server only comes installed with Lion Server – if you’re running the desktop you’ll still need to install it.