如何启动Postgres服务器? [英] How to start Postgres server?

查看:259
本文介绍了如何启动Postgres服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上已经遇到了一段时间,但我终于决定继续解决它。 Postgres最初是使用Brew安装的。



我升级到OSX 10.8.2后收到a

  psql:无法连接到服务器:没有这样的文件或目录
服务器是否在本地运行并且在Unix域套接字 /tmp/.s.PGSQL.5432上接受
连接?

输入



<$ p $时出错p> $ 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 24 32768 596 s002 R + 7 :24PM 0:00.00 grep post


$其中psql
/ usr / local / bin / psql

$ pg_ctl start
pg_ctl :未指定数据库目录,并且未设置环境变量PGDATA
尝试 pg_ctl --help以获取更多信息。


解决方案

您尚未启动Postgres服务器。 Postgres的某些dmg软件包将其设置为在启动时作为服务运行。



您需要初始化一个数据目录,启动postgres,然后从那里开始。

  initdb / some / directory#一次执行一次
pg_ctl -D / some / directory开始#许多其他选项,例如日志记录,此处可用
psql postgres

您可以为数据目录设置环境变量,您以后将不需要 -D 标志。您可以稍后再查找。


Ive actually had this problem for a while but I've finally decided to take it on. Postgres was initially installed using Brew.

After my upgrade to OSX 10.8.2 to receive a

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"?

error when I typed the

$ psql

command.

I see the following processes:

$ 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. 

解决方案

You haven't started the Postgres server. Some of the dmg packages for Postgres set it to run as a service on startup. But not however you did the install.

You need to init a data directory, start postgres, and then go from there.

initdb /some/directory # just do this ONCE
pg_ctl -D /some/directory start # many other options, e.g. logging, available here
psql postgres

You can set an environment variable for the data directory and you won't need the -D flag later. You can look that up later.

这篇关于如何启动Postgres服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆