[英]How to solve psql error: could not connect to server?
我正在嘗試為我的網站安裝 GeoDjango。 為此,我首先需要創建一個 PostgreSQL 數據庫。 按照本教程,我嘗試使用sudo su - postgres
和psql
連接到 PostgreSQL。 問題是我收到這個錯誤: psql: error: could not connect to server: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
我做了一些研究,發現這篇文章解釋了如何解決這個問題。 但是,當我運行sudo service postgresql start
我必須輸入 postgres 的密碼,但我不知道它是什么,我從未為 postgres 創建密碼。 我對此進行了研究,但找不到解決方案,因為所有解決方案都需要先連接到 psql 才能更改現有用戶。 但是我需要先找到密碼才能解決連接psql的問題。
我應該做些什么 ?
提前致謝 !
PS:我在 Ubuntu 終端上使用 Windows 10。
PS2:我發現一些主題說使用 Docker 安裝 PostgreSQL 和 PostGIS 更容易。 但是,由於我使用的是 Windows 10,Docker 存在很多兼容性問題。您認為我應該使用 Docker 嗎?
我找到了解決方案!
因此,對於那些感興趣的人,我必須更改密碼才能登錄並解決psql error: could not connect to server
。 要更改密碼,只需輸入sudo passwd postgres
並設置新密碼。 我希望這會幫助其他人!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.