簡體   English   中英

initdb:錯誤:無法創建目錄“./PostgreSQL”:權限被拒絕

[英]initdb: error: could not create directory “./PostgreSQL”: Permission denied

這是我第一次在我的 windows 8.1 上設置數據庫(postgresql 12)

從這個領域的許多相關問題中努力尋找解決方案已經 4 天了,但沒有成功找到答案(無論我不理解它們還是它們在我的情況下不起作用)。

所以,在這里,我將一步一步地解釋我做了什么以及我在每個階段遇到了什么錯誤(它們可能不會相互影響,但我會提到所有錯誤):

當我以管理員身份安裝 PostgreSQL 時,在該過程結束時我收到此錯誤:“無法將 SQL 模塊加載到數據庫集群中”我重新安裝了兩次,但似乎每次都彈出。 在這里,在這篇文章中,我發現有人遇到了同樣的問題,但我從技術上不明白解決方案是什么,不幸的是: Failed to load sql modules into the database cluster during PostgreSQL Installation. 因此,我只是跳過它,一切似乎都很好。

然后我在高級系統設置中設置 PATH -> 環境變量(在用戶變量和系統變量框中),如下所示:“;C:\Program Files\PostgreSQL\12\bin;C:\Program Files\PostgreSQL\12 \lib"

在這一步之后,我使用 ctrl+R 打開一個終端並輸入 cmd.exe 然后輸入以下代碼:

> cd C:\Program Files\PostgreSQL\12\bin
> initdb -U postgres -A password -E utf8 -W -D .\PostgreSQL\12\data

在這里,我收到了這條消息:

The files belonging to this database system will be owned by user "pc".
This user must also own the server process.

The database cluster will be initialized with locale "English_United States.1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password:
Enter it again:

輸入密碼后,我收到此錯誤:

    The files belonging to this database system will be owned by user "pc".
This user must also own the server process.

The database cluster will be initialized with locale "English_United 
States.1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password:
Enter it again:

creating directory /PostgreSQL/12/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... windows
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Tehran
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctl -D ^"^\PostgreSQL^\12^\data^" -l logfile start

但是在輸入建議的代碼時(無論使用日志文件還是其他文件名),我都會收到以下消息:

waiting for server to start....Access is denied.
 stopped waiting
pg_ctl: could not start server
Examine the log output.

另一方面,當我嘗試 pgAdmin4 瀏覽器界面時,當我在彈出的 window 中右鍵單擊服務器-->創建-->服務器時,我填寫了以下字段:

在常規選項卡上,我將“名稱”框填寫為“dbserver”,我的“用戶名”設置為“postgres”,然后在連接選項卡上,我將“主機”設置為“本地主機”和“密碼”,就像我之前設置的一樣。

這是我得到的錯誤:

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

有人可以幫我解決這個問題嗎?

謝謝

所以,我找到了答案,我想分享它。 我打開 postgres.conf 文件並注釋掉 logging_collector、log_directory 和 log_destination。 我保存了文件。

然后在終端中,我輸入了如下建議的代碼:

pg_ctl -D ^"^\PostgreSQL^\12^\data^" start

服務器啟動了。

現在在 pgAdmin4 瀏覽器中,問題也消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM