Created
February 29, 2012 19:28
-
-
Save trevorsheridan/1943794 to your computer and use it in GitHub Desktop.
Installing PostgreSQL on Mac OS X Lion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Postgres manual located here: http://www.postgresql.org/docs/8.4/interactive/index.html | |
These instructions should work for Postgres 8 and 9 | |
1. INSTALL | |
$ cd ~/source | |
$ ftp http://ftp.postgresql.org/pub/source/v8.4.11/postgresql-8.4.11.tar.gz | |
$ tar -zxvf postgresql-8.4.11.tar.gz | |
$ rm -r postgresql-8.4.11.tar.gz | |
$ cd postgresql-8.4.11 | |
$ ./configure | |
$ make | |
$ sudo make install | |
$ make clean | |
$ echo "export PATH=/usr/local/pgsql/bin:\$PATH" >> ~/.profile | |
$ source ~/.profile | |
$ psql —version | |
2. INITIALIZE A DATABASE CLUSTER | |
$ sudo chown -R trevorsheridan:admin /usr/local/pgsql | |
$ initdb -D /usr/local/pgsql/data | |
3. CREATE A LAUNCH DAEMON | |
Move the org.postgres.postgresd.plist file into /Library/LaunchDaemons | |
$ sudo launchctl load -w /Library/LaunchDaemons/org.postgresql.postgresqld.plist | |
4. CREATE A SUPER USER (optional) | |
$ createuser trevorsheridan (set the SUPERUSER options to yes) | |
$ psql -d postgres -U trevorsheridan | |
postgres=# CREATE DATABASE trevorsheridan OWNER trevorsheridan; | |
poostgrs=# \q | |
5. SUCCESS! | |
If all goes well you should be able to login to Postgres by executing the command: | |
$ psql | |
Some quick commands to verify Postgres is working: | |
postgres=# \l [Enter] // List all databases | |
postgres=# \q [Enter] // Quit Postgres | |
6. ADDING A ROLE FOR RAILS | |
postgres=# CREATE USER someone WITH CREATEDB; | |
postgres=# \q | |
7. A NOTE ABOUT THE PG RUBY GEM | |
If you've installed Postgres AFTER you've installed the "pg" gem (via gem install or bundle install), you need to uninstall the PG gem and reinstall: | |
$ gem uninstall pg | |
$ bundle install | |
8. ALTERNATE WAYS TO START THE SERVER | |
This should never need to be used. If you've installed the launchd config, use that instead. | |
Start the server using the cluster located at /usr/local/pgsql/data | |
$ pg_ctl -D /usr/local/pgsql/data/ start | |
or | |
$ postgres -D /usr/local/pgsql/data | |
Stop the server | |
$ pg_ctl -D /usr/local/pgsql/data/ stop | |
9. WITH POSTGRES USER | |
If you've followed other instructions and manually created a postgres system user. You may need to | |
prepend the following to your commands: sudo -u postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace with your username on the line that reads: $ sudo chown -R trevorsheridan:admin /usr/local/pgsql