postgres中的权限被拒绝

时间:2017-06-01 07:01:44

标签: postgresql chmod

我错过了chmod和权限。 现在访问文件夹时出现了很多问题。

如果我启动服务器,我会在浏览器中看到:

 could not connect to server: Connection refused    Is the server running
     on host "localhost" (::1) and accepting    TCP/IP connections on port
     5432? 
could not connect to server: Connection refused     Is the server
     running on host "localhost" (127.0.0.1) and accepting  TCP/IP
     connections on port 5432?

命令

  

service --status-all

告诉postgres的作品

  

[+] postgresq作品

接下来我更改了下一个文件

  

sudo nano /etc/postgresql/9.5/main/postgresql.conf

#listen_addresses = 'localhost'

listen_addresses = 'localhost, server_ip, *'
  

sudo nano /etc/postgresql/9.5/main/pg_hba.conf

添加

host    all         all         server_ip/24    trust

然后命令

  

psql -U postgres -h server_ip

和错误

psql: could not connect to server: Connection refused
    Is the server running on host "95.213.200.26" and accepting
    TCP/IP connections on port 5432?
The following chain of actions leads to a slightly different error

命令

  

哪个psql

答案

/usr/bin/psql
  

sudo su - postgres

No directory, logging in with HOME=/
  

的psql

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

我必须在这里更改文件权限吗?

3 个答案:

答案 0 :(得分:0)

检查listen addres语法。使用:

listen_addresses ='*'

让服务器同时侦听localhost和服务器ip。

答案 1 :(得分:0)

检查服务器上的unix_socket_directories是否设置为与编译客户端时配置的默认套接字目录相同的目录(/var/run/postgresql)(这需要重新启动服务器)。

或者,您可以使用--host的{​​{1}}选项或设置psql环境变量来告诉客户端在PGHOST中查找套接字文件,其中服务器创建它。

看起来客户端和服务器来自不同的安装,否则配置的默认值应该相同。或者您偶然设置了错误的/tmp环境变量。

答案 2 :(得分:0)

这个问题真的很难。我对/文件夹的权限777犯了一个大错,整个系统崩溃了。所以它真的很容易删除服务器并启动新项目。

请删除此问题。我甚至无法检查答案是否有效。 我不能自己删除问题,因为它有一些答案,但它们不会工作。

相关问题