This guide walks you through setting up PostgreSQL for the Koyjak project on a Linux server.
sudo apt update
sudo apt install postgresql
## Enable and start the PostgreSQL service:
sudo systemctl enable postgresql
sudo systemctl start postgresql
Login to postgresql and create db
sudo -u postgres psql
## if sudo -u postgres psql not working or ask for password and still wrong follow next step
Edit the pg_hba.conf file to allow password-based local access:
sudo nano /etc/postgresql/*/main/pg_hba.conf
Update or add this :
# Allow local connections with MD5 password authentication
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
# Replication settings (optional)
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
restart postgresql
sudo systemctl restart postgresql
no try to login and create database
sudo -u postgres psql
## write
CREATE DATABASE koyjak;
now you have created database
Use pg_restore to import your SQL dump:
cd migrations
pg_restore --clean -U postgres -d koyjak ./db.sql
sudo -u postgres psql
\c koyjak
or you can export it
pg_dump -U postgres -h localhost -p 5432 koyjak > database.sql
To increase system semaphore limits for PostgreSQL:
sudo nano /etc/sysctl.conf
and add this:
kernel.sem = 250 32000 100 128
Then apply the changes:
sudo sysctl -p