Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL server wouldn't shutdown on Lion (Mac OS 10.7)

I installed PostgreSQL using Homebrew on Lion. It starts okay but wouldn't shutdown. I tried:

$ #started with $ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start $ #tried stoping with $ pg_ctl -D /usr/local/var/postgres stop -m immediate waiting for server to shut down................................... failed pg_ctl: server does not shut down 

I fixed this issue by deleting the Launch Agent:

launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist rm ~/Library/LaunchAgents/org.postgresql.postgres.plist 
like image 333
Greg Avatar asked Aug 05 '11 01:08

Greg


People also ask

How do you check if Postgres is running on Mac?

psql -c "SELECT 1" -d {dbname} > /dev/null || postgres -D /usr/local/var/postgres >postgres. log 2>&1 & if you want to check and start postgres in one go (handy for automation scripts).

Why my PostgreSQL is not working?

First make sure PostgreSQL server has been started to remote server. If it is running and you get above error, you need to add enable TCP/IP support. By default, the PostgreSQL server only allows connections to the database from the local machine or localhost. This is a security feature.

Where is Postgres stored on Mac?

The actual database files will be under /usr/local/var/postgres after you create the database.


2 Answers

launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist rm ~/Library/LaunchAgents/org.postgresql.postgres.plist 
like image 164
Greg Avatar answered Sep 21 '22 19:09

Greg


Shutting down PostgreSQL Server with -m immediate is a dangerous way to do it, because “Immediate” mode will abort all server processes without a clean shutdown.

This will lead to a recovery run on restart. Try to shutdown PostgreSQL with parameter -m fast instead. "Fast” mode does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected

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

For more information about pg_ctl please visit http://www.postgresql.org/docs/9.0/static/app-pg-ctl.html

like image 44
francs Avatar answered Sep 18 '22 19:09

francs