Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop postgreSQL service on Mac via terminal

Running postgreSQL 9.4.5_2 currently

I have tried

pg_ctl stop -W -t 1 -s -D /usr/local/var/postgres -m f

Normally no news is good news but after I will run

pg_ctl status -D /usr/local/var/postgres 

and get pg_ctl: server is running (PID: 536)

I have also tried

pg_ctl restart -w -D /usr/local/var/postgres -c -m i

Response message is:

waiting for server to shut down.......................... failed
pg_ctl: server does not shut down

I've also checked my /Library/LaunchDaemons/ to see why the service is starting at login but no luck so far. Anyone have any ideas on where I should check next? Force quit in the activity monitor also isn't helping me any.

like image 771
Andrew M Avatar asked Dec 09 '15 07:12

Andrew M


People also ask

How do I start PostgreSQL on Mac terminal?

`psql` on Terminal To get to the PostgreSQL terminal, open your terminal, start the database services ( brew services start postgresql) , then run psql . Thank you!

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).


2 Answers

Sadly none of the previous answers help me, it worked for me with:

brew services stop postgresql

Cheers

like image 156
lgargantini Avatar answered Sep 22 '22 06:09

lgargantini


I tried various options; finally, the below command worked.

sudo -u postgres ./pg_ctl -D /your/data/directory/path stop

example

sudo -u postgres ./pg_ctl -D /Library/PostgreSQL/11/data stop
like image 34
Rajeev Avatar answered Sep 23 '22 06:09

Rajeev