Reputation: 724
I recently started using arch. (arch version 5.6.4).
I installed postgresql by running:
sudo pacman -S postgresql
I'm following archwiki guide to initialize the database cluster. I switch to the postgres user by running
sudo -iu postgres
After which, I run:
initdb -D /var/lib/postgres/data
I get the following 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".
I figured it wouldn't be wise to remove everything in data, so I made a directory /home/user/postgres/data. After creating this directory, I made postgres its user.
I still get a permissions error when running initdb. I even changed permissions to allow read,write,execute but I can't get past the permission error.
Help?
Upvotes: 3
Views: 27129
Reputation: 101
I did this by removing the file and the following the commands mentioned in reply 1. I ran, step-wise,these commands:
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
Upvotes: 3
Reputation: 703
I resolved this by running the following commands:
sudo mkdir /var/lib/postgres/data
sudo chown postgres:postgres /var/lib/postgres/data
sudo -u postgres initdb -D /var/lib/postgres/data
Upvotes: 12
Reputation: 724
Fixed it myself. Just remove everything in postgres/data and run initdb.
Upvotes: 2