Now that we've installed Postgres, we need to choose a directory where the data directory can be created. This data directory will be used to store the databases and the underlying objects we create. To create a data directory, we must use initdb. In this recipe, we shall see the steps involved in initializing a PostgreSQL cluster using initdb.
Getting ready
The postgresql13-server package must be installed on the database server for us to use initdb. Follow the previous recipe to perform the installation. $PGDATA is the environment variable used by Postgres to identify its data directory. This variable can be optionally set in .bash_profile of the Postgres home directory to avoid passing the data directory location to initdb.
How to do it...
In this recipe, we will be using the default data directory for PostgreSQL 13 on CentOS/RedHat and using initdb to initialize the data directory. Let's get started:
- Set the location of...