Even though I’m stupidly busy with my current work I’ve started getting ready for my next gig. As this has ment installing Postgresql on my Macbook for the first time I thought I’d quickly share the solution to the pain I went through in getting it to work.
I received two suggestions for the ‘best install method’, firstly MacPorts and then later pre-compiled dmg’s from Kyng Chaos. I already use ports extensively making that choice easy for me – I like being able to uninstall things if they don’t work to well and was concerned the dmg option wouldn’t allow me to.
sudo port install postgresql83 postgresql83-doc postgresql83-server postgis
I then added the following to my path in ~/.zshrc so I could actually run things
/opt/local/lib/postgresql83/bin
and started the server.
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist
All seemed to be fine and dandy as I could connect with pgAdmin. I quickly discovered that I needed to create a user with the same login as my osx login when I tried creating a test db.
Next I tried restoring my client’s db dump and it barfed big time. As I’ll be working on some mapping software I’d installed the PostGIS package which seems to have failed to link up with Postgres properly. I was getting the follow missing library error:
could not load library /usr/lib/postgresl/liblwgeom.so.1.3
Obviously it’s looking in the wrong place for a start, so I setup a LIBDIR export in my profile to get over that problem and restarted the server.
export LIBDIR=/opt/local/lib/postgresql83
That still didn’t solve the problem though as I don’t have a file by that name on my system, I do however have liblwgeom.1.3.so which looked to be the same thing. Pretty annoying, but easily solved with a symlink.
cd /opt/local/lib/postgresql83 sudo ln -snf liblwgeom.1.3.so liblwgeom.so.1.3
Then the backup restored like a chalm.
To get Rails talking to Postgresql I needed to install the postgres adapter gem appropriately called ‘postgres’. I didn’t expect that to work straight off though as I’d installed postgresql with ports and the gem by default would be looking in the wrong place for it. I was correct, but I also received an additional error complaining about the architechture not being specified – I needed to tell it I wanted i386.
sudo env ARCHFLAGS="-arch i386" gem install postgres -- --with-pgsql-include-dir=/opt/local/include/postgresql83l --with-pgsql-lib-dir=/opt/local/lib/postgresql83/
I gropped around for a bit trying to figure out the correct way of letting it know and eventually found the above solution on code snippets.
No related posts.
![[del.icio.us]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/digg.png)
![[dzone]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/dzone.png)
![[Fark]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/fark.png)
![[Google]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/google.png)
![[LinkedIn]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/linkedin.png)
![[Reddit]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/reddit.png)
![[Shoutwire]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/shoutwire.png)
![[Slashdot]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/slashdot.png)
![[Sphinn]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/sphinn.png)
![[StumbleUpon]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/technorati.png)
![[Twitter]](http://www.motionstandingstill.com/wp-content/plugins/bookmarkify/twitter.png)



3 Comments
hey the new look of your blog is really nice, love it :D
I really hate pgAdmin, this program just doesn’t feel like OS X and it is buggy, I really want something like cocoamysql for postgreSQL in OS X.
Alternatively you could use http://phppgadmin.sourceforge.net/ which I’ve not yet installed – but it’s actually what the main guy at my next gig uses. It’s like phpmyadmin but for postgres.