簡體   English   中英

/var/lib/postgres/data 存在但不為空

[英]/var/lib/postgres/data exists but is not empty

我最近開始使用拱門。 (拱版本 5.6.4)。

我通過運行安裝了 postgresql:

sudo pacman -S postgresql

我正在按照 archwiki 指南來初始化數據庫集群。 我通過運行切換到 postgres 用戶

sudo -iu postgres

之后,我運行:

initdb -D /var/lib/postgres/data

我得到以下 output:

[postgres@archlinux ~]$ initdb -D /var/lib/postgres/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: error: directory "/var/lib/postgres/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/postgres/data" or run initdb
with an argument other than "/var/lib/postgres/data".

我認為刪除數據中的所有內容是不明智的,所以我創建了一個目錄 /home/user/postgres/data。 創建此目錄后,我將 postgres 設為其用戶。

運行 initdb 時仍然出現權限錯誤。 我什至更改了權限以允許讀取、寫入、執行,但我無法通過權限錯誤。

幫助?

自己修好了。 只需刪除 postgres/data 中的所有內容並運行 initdb。

我通過運行以下命令解決了這個問題:

sudo mkdir /var/lib/postgres/data

sudo chown postgres:postgres /var/lib/postgres/data

sudo -u postgres initdb -D /var/lib/postgres/data

我通過刪除文件和以下回復 1 中提到的命令來做到這一點。我逐步運行了這些命令:

**sudo rm -rf /var/lib/postgres/data

sudo mkdir /var/lib/postgres/data

sudo chown postgres:postgres /var/lib/postgres/data

sudo -u postgres initdb -D /var/lib/postgres/data**

暫無
暫無

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

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