Postgresql – Admin Commands Short List

HomeDocs >

Determining if Postgres is Running

[sourcecode language=”bash”]
ps aux | grep postgres
[/sourcecode]

The installation directory generally looks something like this.

[sourcecode language=”bash”]
/Library/PostgreSQL
[/sourcecode]

However Postgres has and continues to have various disparate installation paths depending on the installation method. Maybe they’ve been synchronized, but I don’t hedge bets on it and just assume I’ll have to find it.

Easy Installations

There is an actual installer for Windows, OS-X, and other platforms available via EnterpriseDB. I’d however advise NOT to use this installer. The more generally accepted installation method is to use homebrew or other alternates on Linux. As for Windows, this is another situation I’d suggest just not running Windows as it would be easier and less frustrating.

With homebrew it’s easy to get a good installation following these steps. It is always good to kick off with a brew update and doctor to make sure things are ok on the system.

[sourcecode language=”bash”]
brew update
brew doctor
[/sourcecode]

Then give it the ole’ brew install.

[sourcecode language=”bash”]
brew install postgresql
[/sourcecode]

Now setup the initial database, which you’ll have to do.

[sourcecode language=”bash”]
initdb /usr/local/var/postgres -E utf8
[/sourcecode]

Now let’s setup launch. Mind you, make sure to check what version of Postgres you’re install as the version below may be different than what I’ve used.

[sourcecode language=”bash”]
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.2.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
[/sourcecode]

Now run Launch Control.

[sourcecode language=”bash”]
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
[/sourcecode]

…and that should get everything up and running.

This site uses Akismet to reduce spam. Learn how your comment data is processed.