Small correction in chown command to set the owner of the pgsql data dir correctly

From: PG Doc comments form <noreply(at)postgresql(dot)org>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Cc: samantaswarnava1(at)gmail(dot)com
Subject: Small correction in chown command to set the owner of the pgsql data dir correctly
Date: 2021-02-07 06:47:02
Message-ID: 161268042200.663.5503825431641757282@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/13/creating-cluster.html
Description:

"root# mkdir /usr/local/pgsql
root# chown postgres /usr/local/pgsql
root# su postgres
postgres$ initdb -D /usr/local/pgsql/data"
If these steps are followed then it still fails to initialize the DB as
chown only gives ownership to the pgsql directory but not the child
directories under pgsql, where potentially a data directory is to be created
by a new user. And it fails giving a output like this
"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 locales
COLLATE: en_IN.UTF-8
CTYPE: en_IN.UTF-8
MESSAGES: en_IN.UTF-8
MONETARY: en_IN
NUMERIC: en_IN
TIME: en_IN
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.

fixing permissions on existing directory /usr/local/pgsql/data ... initdb:
error: could not change permissions of directory "/usr/local/pgsql/data":
Operation not permitted"

Now if we recursively give permission with chown to the pgsql dir with
"root# chown -R postgres /usr/local/pgsql", the potential data directory now
also has ownership given to postgres user and the init db command succeeds

"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 locales
COLLATE: en_IN.UTF-8
CTYPE: en_IN.UTF-8
MESSAGES: en_IN.UTF-8
MONETARY: en_IN
NUMERIC: en_IN
TIME: en_IN
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.

fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/****
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

pg_ctl -D /usr/local/pgsql/data -l logfile start"

Thus, it successfully sets the cluster.

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Dariusz Daćko 2021-02-07 11:04:49 Re: The synopsis of "ALTER DEFAULT PRIVILEGES" statement is too difficult to understand
Previous Message Tatsuo Ishii 2021-02-07 04:53:56 Re: pg_wal_lsn_diff