postgresql - 在 mac 上启动 - `pg_ctl` 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16118723/
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 00:53:04  来源:igfitidea点击:

postgresql - start on mac - `pg_ctl` not working

databasepostgresqlshellcommand-line

提问by Lucy Weatherford

I want to use the pre-installed postgresql on my local machine (mac os 10.7.5), when I run which psqlI find it (in /usr/bin/psql), but then running

我想在我的本地机器(mac os 10.7.5)上使用预装的 postgresql,当我运行时which psql我发现它(在/usr/bin/psql),但然后运行

pg_ctl -D /usr/bin/psql -l /usr/bin/psql/server.log start

results in:

结果是:

-bash: pg_ctl: command not found

How can I start/use my postgresql database? do I need to install it (with say Homebrew) or can I use the pre-installed one on my mac? I also tried using the initdbcommand (initdb /usr/bin/psql -E utf8) and also go tthe same message: -bash: initdb: command not found.

如何启动/使用我的 postgresql 数据库?我需要安装它(比如 Homebrew)还是我可以在我的 mac 上使用预装的?我也尝试使用initdb命令 ( initdb /usr/bin/psql -E utf8) 并且也得到相同的消息:-bash: initdb: command not found.

Also, is this psqlthe same as postgres? (I tried which postgresand got nothing)

另外,这psqlpostgres? (我试过which postgres了,一无所获)

Update: I'm using psqlcommands in the command line, but am getting there the following message (for psql -land psql -afor instance):

更新:我使用psql的命令在命令行,但我越来越有下列消息(psql -lpsql -a为例):

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

采纳答案by Chris Farmiloe

OS X ships with the command line client (for interacting with postgres databases) not the server.

OS X 附带命令行客户端(用于与 postgres 数据库交互)而不是服务器。

You need to install the server.

您需要安装服务器。

Check the postgres siteor grab the postgres.app

检查postgres 站点或获取postgres.app