Comment 6 for bug 2067061

Revision history for this message
kartikey (mishrakartik) wrote :

 # Stop PostgreSQL Service
sudo systemctl stop postgresql

# Remove the Data Directory
sudo rm -rf /var/lib/postgresql/15/main

# Recreate the Data Directory
sudo mkdir -p /var/lib/postgresql/15/main
sudo chown -R postgres:postgres /var/lib/postgresql/15/main
sudo chmod -R 700 /var/lib/postgresql/15/main

# Verify Directory is Empty
sudo ls -l /var/lib/postgresql/15/main

# Reinitialize the Database Cluster
sudo -u postgres /usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/15/main

# Start PostgreSQL Service
sudo systemctl start postgresql

# Check Service Status
sudo systemctl status postgresql
total 0
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 locale "en_US.UTF-8".
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 /var/lib/postgresql/15/main ... 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/Kolkata
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
initdb: hint: 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:

    /usr/lib/postgresql/15/bin/pg_ctl -D /var/lib/postgresql/15/main -l logfile start

Job for postgresql.service failed because the control process exited with error code.
See "systemctl status postgresql.service" and "journalctl -xeu postgresql.service" for details.
× postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/etc/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2024-06-07 14:06:05 IST; 37ms ago
       Docs: man:postgres(1)
    Process: 82985 ExecStart=/usr/lib/postgresql/15/bin/pg_ctl start -D /var/lib/postgresql/15/main -s -o -c config_file=/etc/postgresql/15/m>
        CPU: 27ms

Jun 07 14:06:05 kartik-81WE systemd[1]: Starting postgresql.service - PostgreSQL RDBMS...
Jun 07 14:06:05 kartik-81WE pg_ctl[82985]: pg_ctl: another server might be running; trying to start server anyway
Jun 07 14:06:05 kartik-81WE pg_ctl[82985]: pg_ctl: could not start server
Jun 07 14:06:05 kartik-81WE pg_ctl[82985]: Examine the log output.
Jun 07 14:06:05 kartik-81WE systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
Jun 07 14:06:05 kartik-81WE systemd[1]: postgresql.service: Failed with result 'exit-code'.
Jun 07 14:06:05 kartik-81WE systemd[1]: Failed to start postgresql.service - PostgreSQL RDBMS.
lines 1-14/14 (END)