install PostgreSQL on Ubuntu 20.04

Step 1 — Installing PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib
Step 2 — Create PostgreSQL Roles and Databases
we will create OS user jiradb, postgresql role jiradb and database jiradb!
A. with root add OS user: adduser jiradb
B. add postgresql role:
root@ubunu2004:/opt/jira/lib# sudo -i -u postgres
postgres@ubunu2004:~$ createuser –interactive
Enter name of role to add: jiradb
Shall the new role be a superuser? (y/n) y
C. create db:
postgres@ubunu2004:~$ createdb -E UNICODE -l C -T template0 jiradb
postgres@ubunu2004:~$ psql
postgres=# GRANT ALL PRIVILEGES ON DATABASE jiradb TO jiradb
postgres-# \q
Step 3 — Test the connection
postgres@ubunu2004:~$ psql -U jiradb -h localhost -W
Password:
psql (12.2 (Ubuntu 12.2-4))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
jiradb=# \z

NOTE:
You can now start the database server using:
pg_ctlcluster 12 main start
Data directory: /var/lib/postgresql/12/main
Log file: /var/log/postgresql/postgresql-12-main.log
Port: 5432

Leave a Reply

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