How to Install PostgreSQL 17 on Fedora 42

Database PostgreSQL

Installing PostgreSQL 17 on Fedora 42

Update package repository cache

sudo dnf makecache

Install PostgreSQL 17 client and server packages

sudo dnf install postgresql17 postgresql17-server

Initializing PostgreSQL 17 Data Directory

Initialize the PostgreSQL database directory

sudo /usr/bin/postgresql-setup --initdb

Starting PostgreSQL 17

Start PostgreSQL 17 systemd service

sudo systemctl start postgresql.service

Add PostgreSQL service to system startup so that it starts automatically at system boot

sudo systemctl enable postgresql.service

PostgreSQL 17 should be running

sudo systemctl status postgresql.service

Configuring PostgreSQL 17 for Password Authentication and Remote Login

Open the pg_hba.conf file with nano text editor

sudo nano /var/lib/pgsql/data/pg_hba.conf

Change IPv4 local connection configuration to the following:

host all all 0.0.0.0/0 md5

Save the changes to the pg_hba.conf file and restart PostgreSQL service

sudo systemctl restart postgresql.service

Setting a Password for the postgres User

Login as the Linux postgres user

sudo su - postgres

Access the PostgreSQL database

psql

Set a password for the postgres PostgreSQL database user

ALTER USER postgres PASSWORD 'secretPass123'; 

Accessing PostgreSQL Server Remotely

To access the PostgreSQL database remotely, install the PostgreSQL client on your computer and run the following command:

psql --username=postgres --host=<ip-postgres-server> --password

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *