2013-04-20 208 views
6

我想在我的本地机器上使用预安装的postgresql(mac os 10.7.5),当我运行which psql时我发现它(在/usr/bin/psql),但后来运行postgresql - 在Mac上启动 - `pg_ctl`不工作

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

结果:

-bash: pg_ctl: command not found 

我如何启动/用我的PostgreSQL数据库?我是否需要安装它(用Homebrew说)或者我可以使用我的Mac上预装的吗? 我也尝试使用initdb命令(initdb /usr/bin/psql -E utf8),并且也使用相同的消息:-bash: initdb: command not found

另外,这是psql是否与postgres相同? (我试过which postgres并没有什么)

更新:我使用的命令行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"? 
+0

感谢上帝这个问题是不会被删除。投票重新开放。 – djechlin 2014-06-01 15:00:45

回答

5

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

您需要安装服务器。

检查the postgres site或抢postgres.app

+1

谢谢,我现在试了postgerapp,并更新了'.zshrc'文件中的路径,但仍然收到相同的错误:'psql:无法连接到服务器:没有这样的文件或目录 服务器是否在本地运行,在Unix域套接字上接受 连接“/var/pgsql_socket/.s.PGSQL.5432”?' – 2013-04-20 11:54:29

+0

我最终使用自制软件来安装postgres本身 – 2013-04-20 19:25:49