Home Postgres init setup
Post
Cancel

Postgres init setup

Install postgres

1
2
3
apt update
apt upgrade -y
apt install postgresql postgresql-contrib -y

Set password for postgres user

switch to postgres user

1
su - postgres

enter postgres shell

1
psql

set password for postgres user

1
\password postgres

Postgres config file

1
2
vim /etc/postgresql/14/main/postgresql.conf
vim /etc/postgresql/14/main/pg_hba.conf

after editing, restart postgres

1
systemctl restart postgresql

Cancel peer authentication for postgres user

1
vim /etc/postgresql/14/main/pg_hba.conf

change

1
local   all             postgres                                peer

to

1
local   all             postgres                                md5

Create new user

1
2
su - postgres
createuser --help

Create new database

1
2
su - postgres
createdb yourdbname
This post is licensed under CC BY 4.0 by the author.

How to use nginx to setup https with certbot and let's encrypt

Linux regular cmd