2

I am trying to set up PostgreSQL in Linux, but the following error comes up:

[postgres@kibearch ~]$ initdb --pgdata=/var/lib/pgsql/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.

creating directory /var/lib/pgsql/data ... initdb: error: could not create directory "/var/lib/pgsql": Permission denied

If I try to use sudo initdb --pgdata=/var/lib/psql/data/, it says that initdb can not be used with sudo.

Here are the steps I did:

  1. sudo pacman -S postgresql
  2. Switched to user postgres user using this command: su - postgres
  3. Tried to initialize the server but the aforementioned error showed up

What can I do?

1
  • use a directory writeable by user postgres. What is your postgres users ~ ? Commented Oct 5, 2020 at 21:48

1 Answer 1

4

As root:

mkdir /var/lib/pgsql
chown postgres  /var/lib/pgsql

As postgres:

initdb --pgdata=/var/lib/pgsql/data
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.