postgresql 连接 psql 时出现问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16192731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 00:53:15  来源:igfitidea点击:

Issues while connecting psql

linuxpostgresqlopensuse

提问by user1778824

I installed postgresql in accordance with the instructions given at: http://xadmin.info/?p=284

我按照以下说明安装了 postgresql:http: //xadmin.info/?p=284

# pg_ctl -D /var/lib/pgsql/data -l pglog.log start
server starting
postgres@linux-p0pl:~> psql
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"?

I am not getting as to why am I getting this error when the server has started...can someone please please help.

我不明白为什么在服务器启动时我会收到这个错误......有人可以帮忙吗?

My pglog.log file shows the following output:

我的 pglog.log 文件显示以下输出:

2013-02-06 19:43:39 GMT   FATAL:  lock file "postmaster.pid" already exists
2013-02-06 19:43:39 GMT   HINT:  Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"?
2013-02-06 19:44:02 GMT   FATAL:  lock file "postmaster.pid" already exists
2013-02-06 19:44:02 GMT   HINT:  Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"?
2013-04-24 12:43:29 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:43:29 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:44:07 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:44:07 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:57:02 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:57:02 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:57:40 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:57:40 GMT   DETAIL:  Permissions should be u=rwx (0700).

ps -ef | grep postgres

ps -ef | grep postgres

root     21659 21591  0 19:14 pts/0    00:00:00 grep --color=auto postgres

回答by Clodoaldo Neto

The permissions and ownership on /var/lib/pgsql/datashould be:

权限和所有权/var/lib/pgsql/data应该是:

# ll -d /var/lib/pgsql/data
drwx------. 15 postgres postgres 4096 Apr 24 10:27 /var/lib/pgsql/data

If they are not do as root:

如果他们不是以 root 身份执行:

# chmod -R 700 /var/lib/pgsql/data
# chown -R postgres /var/lib/pgsql/data

回答by Ed Plese

Check in the pglog.logfile to ensure that the server did actually start without error. Given the error it seems like it did not start properly.

签入pglog.log文件以确保服务器确实启动且没有错误。鉴于错误,它似乎没有正确启动。

回答by Richard Huxton

You probably don't have your server configured to put unix domain sockets in "/tmp". It's probably somewhere like "/var/run/pgsql" but see your postgresql.conffile to see exactly what.

您可能没有将服务器配置为将 unix 域套接字放在“/tmp”中。它可能类似于“/var/run/pgsql”,但请查看您的postgresql.conf文件以了解确切内容。

Then you can specify this directory as a "host" on the command-line:

然后您可以在命令行上将此目录指定为“主机”:

psql -h /path/we/want ...

If that's not the problem, check the port number.

如果这不是问题,请检查端口号。

Not sure why/how your psql client and postgresql server have different default paths, but then I've never heard of the site you got the instructions from, so I've no idea how useful they are.

不知道为什么/如何您的 psql 客户端和 postgresql 服务器有不同的默认路径,但是我从来没有听说过您从中获得说明的站点,所以我不知道它们有多大用处。