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.
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.
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.
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).
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With