How to find out if a directory is a valid PostgreSQL cluster

Use the following commands to initialize the DB directory.

$ initdb -D <data_directory>

Then you can get the information about initialization.

By the way, if you want to start your psql quickly, set PGDATA variable in configuration file, then use pg_ctl start to start your psql.


To start first time your Postgres server with single node. We should following steps,

Step 1. Create directory let say: /home/rajeev/pg_data_1

Step 2. initialize the cluster that copy all exe, lib, dependency config etc. postgres_home> initdb -D /home/rajeev/pg_data_1

if successfull initialize your server you will get following log message

Success. You can now start the database server using: pg_ctl -D ^"/home/rajeev/pg_data_1" -l logfile start

Step 3: Start Postgres node $postgres_home>pg_ctl.exe -D /home/rajeev/pg_data_1 start -U postgres -P pass123 -S auto

Step 4: start postgress CLI

psql -U postgres

Tags:

Postgresql