postgres不知道在哪里可以找到服务器配置

Mis*_*cha 19 postgresql

我试图在我的新Mac上运行PostgreSQL for RoR(我是新手).我按照安装指南,但我无法正常工作.我发现了类似的问题,但那些没有帮助.我在'postgres'cmd上收到以下错误.

postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the 
PGDATA environment variable.
Run Code Online (Sandbox Code Playgroud)

但是当我设置我的-D调用时

postgres -D /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)

我收到另一个错误

FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 6621) running in data directory    
"/usr/local/var/postgres"?
Run Code Online (Sandbox Code Playgroud)

我试图使用'kill 6621'然后它似乎只是在另一个PID上启动另一个postmaster.我也试过删除PID并运行

postgres -D /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

LOG:  could not bind IPv6 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG:  could not bind IPv4 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING:  could not create listen socket for "localhost"
FATAL:  could not create any TCP/IP sockets
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?

Fra*_*uga 22

通常,在安装postgres时,会在系统中创建服务/守护程序,因此无需手动启动服务器.您收到错误,因为该服务已在运行.

尝试使用连接到数据库 psql


kes*_*lal 7

就我而言,我必须使用主机名创建一个新数据库

createdb hostname
Run Code Online (Sandbox Code Playgroud)

我想任何其他名字也可能同样有效。

然后使用psql命令连接到我新创建的数据库。

psql mydbname
Run Code Online (Sandbox Code Playgroud)

工作起来就像一个魅力。