Reputation: 243
I am trying to set up Postgres in Redhat. I do the following steps:
$ sudo yum install postgresql-server postgresql-contrib
It is successfully installed. Then i try to set up a database cluster.
$ initdb -D /usr/local/pgsql/data
I get the error:
initdb: could not access directory "/usr/local/pgsql/data": Permission denied
New to linux. Not being able to move forward
Figured out the solution. I went to the specified folder and changed its access permission. It worked after that.
Upvotes: 5
Views: 20189
Reputation: 7593
The PostgreSQL documentation notes that the /usr/local/pgsql/data
directory needs to be owned by the postgres
user.
To do this, you can run the following command:
chown postgres /usr/local/pgsql/data
And if that doesn't work, you might need to also use sudo
:
sudo chown postgres /usr/local/pgsql/data
Upvotes: 5
Reputation: 13
While installing postgre, I used
su - postgres
to connect to the specific user with root privileges. Then, the following returned a success
/usr/pgsql-9.5/bin/initdb
Upvotes: 0
Reputation: 191
You are running the first command as a superuser and the second as a regular user. Try
sudo initdb -D /usr/local/pgsql/data
Upvotes: 0