erickchali
3/8/2018 - 4:42 PM

CheatSheet

# remove folders and hidden files check with ls -a to get names.
# NEEDS TO BE DONE AS root so login as - su
rm -rf /var/lib/pgsql/*
rm -rf /var/lib/pgsql/backups/*
rm -rf /var/lib/pgsql/data/*

# check on fedora page for database initialization and enabling on boot

# add new user
sudo -u postgres psql postgres
# enter system password

# create user
CREATE USER username WITH PASSWORD 'secret';

# optional add options
ALTER USER username WITH [options]

CREATE DATABASE username OWNER username; # no login if no database

# change configuration on pg_hba.conf to: 

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
systemctl  status postgresql.service
sudo systemctl restart postgresql
--kill user connections to be able to drop the database.
SELECT pg_terminate_backend(pg_stat_activity.pid)
    FROM pg_stat_activity
    WHERE pg_stat_activity.datname = 'target_db' AND pid <> pg_backend_pid();
docker-compose run db psql -U user -h db viewer