30

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?

  • 1
    Are you using the OS X Server.app? – tron_jones Jul 3 '15 at 13:24
  • 1
    How did you install PostgreSQL? There are multiple ways and each may be subtly different. – mjturner Jul 3 '15 at 13:29
30

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
  • This alias does the trick: alias postgresql.server='function pgsql_server() { case $1 in "start") echo "Trying to start PostgreSQL..."; pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start ;; "stop") echo "Trying to stop PostgreSQL..."; pg_ctl -D /usr/local/var/postgres stop -s -m fast ;; esac }; pgsql_server' Commands: postgresql.server start or postgresql.server stop – Igor de Lorenzi Apr 13 '16 at 16:44
45

Brew has that covered:

brew services restart postgresql
  • 1
    I just updated my Postgres via brews (uninstalling the old one), but now Postgresql starts with the yellow color (status unknown). Because of that I can't connect to it Any ideas? – Matheus Felipe Jun 13 '17 at 4:43
  • @MatheusFelipe I suggest to post a dedicated question – Nikita Volkov Jun 13 '17 at 12:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .