Skip to content

Instantly share code, notes, and snippets.

@hartct
Forked from rafaelss/gist:3700977
Last active December 15, 2015 15:09
Show Gist options
  • Save hartct/5279334 to your computer and use it in GitHub Desktop.
Save hartct/5279334 to your computer and use it in GitHub Desktop.
1. launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
2. mv /usr/local/var/postgres9 /usr/local/var/postgres90
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
4. brew install postgresql # if this doesn't work, homebrew may have an existing installation. you can try a brew upgrade postgresql but some of the instructions that follow may need to change...
4b. at this point, check to make sure that the postgres binaries are linked and in the path correctly. try doing psql -V and confirm it shows version 9.2. If it doesn't, adjust your path so /usr/local/Cellar/postgresql/9.2.0/bin/ is in front of the offending locations with postgres binaries in them or fight with brew link to fix it.
5. initdb /usr/local/var/postgres -E utf8
6. Edit ~/Library/LaunchAgents/org.postgresql.postgres.plist file to point to your new locations, probably looking like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.postgresql.postgres</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/postgresql/9.2.0/bin/postgres</string>
<string>-D</string>
<string>/usr/local/var/postgres</string>
<string>-r</string>
<string>/usr/local/var/postgres/server.log</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>chris</string>
<key>WorkingDirectory</key>
<string>/usr/local</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/postgres/server.log</string>
</dict>
</plist>
7. launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
8. ps -ef | grep post # confirm postgres processes are running
9. brew install postgis
10. createdb -h localhost rewardsummit_dev
11. createdb -h localhost rewardsummit_test
12. psql -h localhost -d rewardsummit_dev
In psql run:
CREATE EXTENSION postgis;
CREATE EXTENSION pg_trgm;
\c rewardsummit_test
CREATE EXTENSION postgis;
CREATE EXTENSION pg_trgm;
\q
13. Download a recent dump from the test system
14. pg_restore -h localhost -d rewardsummit_dev --verbose --clean --no-acl --no-owner < test_b006.dump
@hartct
Copy link
Author

hartct commented Mar 31, 2013

These instructions are for a very tailored installation of Postgres and probably will not work for most people!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment