Set Up PostgreSQL on Mac OS 10.5+ Quickly
To install PostgreSQL, use homebrew (the best package manager for Mac; get it here. Then, you can type this to install PostgreSQL:
1
|
|
You will need to create a new postgres user. To create the user account, first find an unused user ID. To see the IDs that are currently in use, type in the Terminal:
1
|
|
Choose one that’s not taken
Then, create the user account _postgres , like so:
1
|
|
1
|
|
(Leopard precedes daemon names with an underscore. The last command created an alias without the underscore, though, so that you can forget the underscore exists.)
By the way, if you need to delete a user on OS 10.5+, you can type this:
1
|
|
The user account is now created. It is not given a password intentionally. This prevents anyone but root from logging in as postgres. To use the postgres user account, type:
1
|
|
Now, as a sudo-capable user, set permissions on the data directory (create it if it’s not there, or delete it’s contents if it has any).
1
|
|
Log back in as postgres (sudo su postgres), and initialize the database cluster:
1
|
|
1 2 3 |
|
1 2 3 |
|
You now can integrate this database into your django (or Rails, or whatever) app. The credentials would be (host: localhost, port:5432, DB: [name of your database], username: [name of your user], password: [none])
I realize I’ve covered nothing but the bare minimum needed to set up PostgreSQL 9 on a local Mac OS 10.6 development machine. I strongly invite you to look at the official documentation, here.
Hopefully, this saves you some time when you’re just trying to get your app working quickly.