I just wasted an entire afternoon getting rails running on PostgreSQL!!!

Submitted by aaron on Fri, 08/13/2010 - 16:24

Here are the notes I took during the epic voyage of getting rails + postgresql working on my macbook in case it helps anyone out there...
 
 
#started with
sudo port -v selfupdate

#then started postgres install via macports
sudo port install postgresql84 postgresql84-server
#failed several times, but got it to work after running the 'clean openssl' command and re-running

#Then, once successful, created a /etc/paths.d/postgres file with:
/opt/local/lib/postgresql84/bin

#after that, restarted in new terminal window to pickup path changes and installed pg gem
sudo env ARCHFLAGS="-arch x86_64" gem install pg

#next ran following commands - note that lines in bold which are different from what the macports output says
sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su - postgres
/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb
createuser --superuser mymacusername -U postgres

#finally, to start db (still as postgres user)
/opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb

#installed pgadmin3 from installer at:
#http://www.postgresql.org/ftp/pgadmin3/release/v1.10.5/osx/
#(do not use macports - blows up)

#used pgadmin to create a myapp_dev database
#Note : had to set pgadmin to use my username to connect - postgres user does not have a password (thus the sudo for the su command above)

#then setup database.yml
#development:
#  adapter: postgresql
#  database: myapp_dev

#finally ran 
rake db:migrate
 

Copyright © 2011, Aaron Blondeau

Drupal theme by Kiwi Themes.