我真的有这个问题了一段时间,但我终于决定采取.最初使用Brew安装Postgres.
升级到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"?
当我打字时出错
$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标志.你可以稍后再看.