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
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).
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.
The actual database files will be under /usr/local/var/postgres after you create the database.
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist rm ~/Library/LaunchAgents/org.postgresql.postgres.plist
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With