2017-06-01 76 views
0

我錯過了一些chmod和權限。 現在有很多訪問文件夾的問題。權限在postgres中被拒絕

如果我啓動服務器我看到瀏覽器:

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? 

命令

服務--status-所有

告訴Postgres的工作

[ +] postgresq作品

接下來,我旁邊的文件

改變

須藤納米/etc/postgresql/9.5/main/postgresql.conf

#listen_addresses = 'localhost' 

listen_addresses = 'localhost, server_ip, *' 

sudo nano/etc/post gresql/9.5 /主/ 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 

須藤蘇 - 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"? 

至極文件的權限做我必須在這裏改變?

+0

運行作爲根'找到/ -name .s.PGSQL.5432'?.. –

+0

它回答/tmp/.s.PGSQL.5432 –

+0

/run/postgresql/.s.PGSQL.5432 –

回答

0

這個問題真的很難。我對/文件夾的權限777發生了很大的錯誤,整個系統崩潰了。所以這真的是easyer刪除服務器並啓動新項目。

請刪除此問題。我甚至無法檢查答案是否可行。 我不能自己刪除問題,因爲它有一些答案,但他們不會工作。

0

檢查監聽地址的語法。用途:

的listen_addresses = '*'

對於服務器監聽本地主機都和服務器IP。

+0

已經做了,如果更新配置仍然有錯誤 –

+0

,應該重新啓動數據庫服務來加載新的配置。如果在debian/ubuntu上:sudo service postgresql restart – anneb

+0

嗯,不能很好地解讀你的問題。您並未嘗試連接網絡套接字。 'psql'作爲用戶'postgres'應該可以工作。你可以嘗試使用網絡連接:'psql -h localhost',但這並不能解釋爲什麼當用戶是postgres時沒有參數的'psql'不起作用(sudo su postgres) – anneb

0

檢查服務器上的unix_socket_directories與客戶端編譯時配置的缺省套接字目錄(這需要服務器重新啓動)設置爲相同的目錄(/var/run/postgresql)。

或者,你可以使用psql--host選項或設置PGHOST環境變量來告訴客戶端來尋找/tmp套接字文件,其中服務器創建它。

它看起來像客戶端和服務器來自不同的安裝,否則兩個配置的默認值應該是相同的。或者你有一個不好的環境變量PGHOST意外設置。

+0

已經嘗試過同樣的錯誤 –

+0

究竟是什麼你試過了嗎? –