How to restart PostgreSQL installed by Brew in OSX

homebrewpostgresql

In Linux, it can be done by /etc/init.d/postgresql-9.2 restart.
My OSX is not a server app.

I think it it can be done by ALTER USER postgres with password '1234'; postgreQSL prompt but I am not sure if it is the meant way.

How can you restart the PostgreSQL server in OSX?

Best Answer

Manually Start PostgreSQL:

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

Manually Stop PostgreSQL:

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

This stackoverflow discussion really goes into some great detail, with many more options. I used it to create an alias to just run:

postgresql.server stop
postgresql.server start