[英]Permission denied in postgres
我錯過了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?
命令
服務--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"?
我必須在這里更改文件權限嗎?
檢查listen addres語法。 采用:
listen_addresses ='*'
讓服務器同時監聽localhost和服務器ip。
檢查服務器上的unix_socket_directories
是否設置為與編譯客戶端時配置的默認套接字目錄相同的目錄( /var/run/postgresql
)(這需要重新啟動服務器)。
或者,您可以使用psql
的--host
選項或設置PGHOST
環境變量,以告訴客戶端在/tmp
查找套接字文件,服務器在其中創建它。
看起來客戶端和服務器來自不同的安裝,否則配置的默認值應該相同。 或者您偶然設置了錯誤的PGHOST
環境變量。
這個問題真的很難。 我對/
folder的權限777犯了一個大錯,整個系統崩潰了。 所以它真的很容易刪除服務器並啟動新項目。
請刪除此問題。 我甚至無法檢查答案是否有效。 我不能自己刪除問題,因為它有一些答案,但他們不會工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.