Thursday, April 20, 2023

Initializing Postgresql server after a fresh install

These brief instructions are from Fedora 38.

Initialize the database


Initialize the database with this command (as root):

/usr/bin/postgresql-setup --initdb

Enable the service and start it


Run these systemctl commands (as root):
systemctl enable postgresql
systemctl start postgresql

Allow local trust for unix and IP4 sockets


Edit the /var/lib/pgsql/data/pg_hba.conf file as root and change the local line to trust:
local all all trust
host all all 127.0.0.1/32 trust

Then, restart the service.

Login as user postgres and create other users and databases


psql -U postgres
create role [user]
create database [user]
alter role [user] with login