Skip to content
leomao10 edited this page Sep 7, 2011 · 5 revisions

PostgreSQL

Installation

Mac

Prequisition:

Following steps are base on assumption that Homebrew is already installed in Mac

Install PostgreSQL library:

brew install postgres

There will be lots of informations shown on your console after you install PostgreSQL. And you can ask homebrew to show it again using this command

brew info postgres

Setup after first install

If this is the first install, create a database with:

initdb /usr/local/var/postgres

And open postgres service when launch Os X:

cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents

launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

Start & Stop

You could start/stop service with these commands:

Start Service: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Stop Service: pg_ctl -D /usr/local/var/postgres stop -s -m fast

Reload Service: pg_ctl reload -D /usr/local/var/postgres/ It is quit useful when you change the conf file and don't want to stop the postgresql

If everything is alright up until now, you should be able to run postgres client application:

psql --verson

And get something like this:

psql (PostgreSQL) 9.0.1

contains support for command-line editing

Ubuntu

Upgrade from 8.4

To be edited

Useful Command

  • \d: Describe an object(databases, tables) in postgreSQL
  • \q: Quit

Replication

Hot Standby

Warm Standby

Cold Standby