Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

could not access directory "/usr/local/pgsql/data": Permission denied ,while trying to setup database cluster

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.

like image 648
Diganta Bharali Avatar asked Jul 14 '16 15:07

Diganta Bharali


People also ask

What is cluster in PostgreSQL?

A database cluster is a collection of databases that is managed by a single instance of a running database server. After initialization, a database cluster will contain a database named postgres , which is meant as a default database for use by utilities, users and third party applications.

What is the default Postgres database?

Switching Databases Most Postgres servers have three databases defined by default: template0 , template1 and postgres . template0 and template1 are skeleton databases that are or can be used by the CREATE DATABASE command. postgres is the default database you will connect to before you have created any other databases.

How do I find my Postgres cluster name?

The cluster name appears in the process title for all server processes in this cluster. Moreover, it is the default application name for a standby connection (see synchronous_standby_names.) The name can be any string of less than NAMEDATALEN characters (64 characters in a standard build).

Does PostgreSQL support clustering?

PostgreSQL does not natively support any multi-master clustering solution like MySQL or Oracle. Nevertheless, many commercial and community products offer this implementation, including replication and load balancing for PostgreSQL.


1 Answers

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
like image 95
summea Avatar answered Sep 22 '22 09:09

summea