通过终端在 Mac 上停止 postgreSQL 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34173451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:06:21  来源:igfitidea点击:

Stop postgreSQL service on Mac via terminal

macospostgresqlpglaunchctl

提问by Andrew M

Running postgreSQL 9.4.5_2 currently

当前正在运行 postgreSQL 9.4.5_2

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)

并得到 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.

我还检查了我的 /Library/LaunchDaemons/ 以了解为什么该服务在登录时启动但到目前为止没有运气。有人对我接下来应该检查的地方有任何想法吗?在活动监视器中强制退出也没有帮助我。

回答by Andrew M

Tried sudo and su but no such luck. Just found this gui

试过 sudo 和 su 但没有这样的运气。刚找到这个gui

https://github.com/MaccaTech/postgresql-mac-preferences

https://github.com/MaccaTech/postgresql-mac-preferences

If anyone can help with the terminal commands that would be very much appreciated, but till then the gui will get the job done.

如果有人可以帮助使用非常感谢的终端命令,但在那之前 gui 将完成工作。

回答by Rajeev

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

回答by jrad

you can stop the server using this command

您可以使用此命令停止服务器

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