Postgresql 如何启动Postgres服务器?
我确实有这个问题有一段时间了,但我最终决定接受它。Postgres最初是使用Brew安装的 升级到OSX 10.8.2后,我将收到Postgresql 如何启动Postgres服务器?,postgresql,osx-lion,django-postgresql,Postgresql,Osx Lion,Django Postgresql,我确实有这个问题有一段时间了,但我最终决定接受它。Postgres最初是使用Brew安装的 升级到OSX 10.8.2后,我将收到 psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 当我输入数据时出错 $ ps
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
当我输入数据时出错
$ psql
指挥部
我看到以下过程:
$ ps auxw | grep post
Tulsa 59222 0.0 0.2 2483256 14808 ?? Ss Thu03PM 0:02.61 /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper -uuid 470DA5CC-1602-4D69-855F-F365A6512F90 -post-exec 4
Tulsa 57940 0.0 0.2 2498852 13648 ?? Ss Wed10PM 0:00.61 /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper -uuid FAFAAAB4-0F67-42C8-864E-EF8C31A42EE3 -post-exec 4
root 24447 0.0 0.1 2476468 10080 ?? Ss 8Feb13 0:03.40 /System/Library/PrivateFrameworks/DiskImages.framework/Resources/diskimages-helper -uuid CC768720-12C2-436C-9020-548C275A6B0C -post-exec 4
Tulsa 74224 0.0 0.0 2432768 596 s002 R+ 7:24PM 0:00.00 grep post
$ which psql
/usr/local/bin/psql
$ pg_ctl start
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
您尚未启动Postgres服务器。Postgres的一些dmg包将其设置为在启动时作为服务运行。但不管你是如何安装的 您需要初始化一个数据目录,启动postgres,然后从那里开始
initdb /some/directory # just do this ONCE
pg_ctl -D /some/directory start # many other options, e.g. logging, available here
psql postgres
您可以为数据目录设置环境变量,以后不需要
-D
标志。你可以稍后再查。我不知道这是怎么回事,但标题是无价的+1@retailcoder:看起来应该是“升级OS/X毁了我的生活。”我很确定-post-exec
与PostgreSQL无关。因此服务器没有在本地运行。在Linux上,它的进程可以通过ps aux | grep postgres
找到。如果这在OS/X上有所不同,我会有点惊讶。按照pg_ctl告诉您的去做。正如错误所说,PGDATA是未设置的
。试试我在这里给出的解决方案,看看它是否适合您:。祝你好运DNo,MacOS X毁了你的生活。看,是的,但是什么目录???我讨厌这些答案。如果我知道哪个目录是一个好的选择,那么我可能不会从S.O.复制粘贴代码。添加“任何目录,例如:/usr/local/var/postgres
”有多难。目录。。。。。啊!我将使用/usr/local/var/db/postgres
mkdir/usr/local/var/postgres/data
,然后将env var PGDATA设置为指向那里,然后pg_ctl-D/usr/local/var/postgres/data start>logfile 2>&1&