psql:无法连接到服务器:权限被拒绝

问题描述:

我一直在努力修复此解决方案。我已经按照多个指引他们都不为我工作..psql:无法连接到服务器:权限被拒绝

于是我打开Postgres的应用程序从我的应用程序文件夹 它抛出日志

FATAL: could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied 
LOG: database system is shut down 

我试着删除以下文件夹中的以下错误但它说PGSQL.5432.lock文件不存在。我已经完成了我的研究,他们都没有为我工作! 我也试过运行psql

psql: could not connect to server: Permission denied 
    Is the server running locally and accepting 
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 

给我那个错误。

+0

/tmp上的权限是什么? ('ls -l/tmp'会告诉你) – jcaron

+0

你试图运行postgresql的用户是什么? – jcaron

+0

@jcaron total 0 -rwxrwxrwx 1 root wheel 0 Nov 28 14:27 .TeamViewer.lock drwxrwxrwx 4 root wheel 136 Nov 28 14:27 natinst – Dilli

psql如果没有指定用户和所有单独运行psqlpsql将您系统的当前用户,如:

[[email protected] ~]# psql 

psqlroot的用户。 所以,你需要告诉psql该用户登录用:

[[email protected] ~]# psql -U postgres 

,你可以看到postgres是默认的用户如果安装过程中没有改变。

如果问题保持你需要找到哪个端口PostgreSQL是使用(您可以在安装过程中更改它)

运行:

[[email protected] ~]# netstat -tulpn | grep postgres 

,你会发现这样的事情:

tcp  0  0 0.0.0.0:5533   0.0.0.0:*    LISTEN  20856/postgres 
tcp6  0  0 :::5533     :::*     LISTEN  20856/postgres 

在我的情况下,端口是5533所以我需要这样做:

[[email protected] ~]# psql -U postgres -p 5533