#21 Django in Production - From Zero to Hero - Part-4

We continue our deployment journey. In this lesson we install database. As database I will use my favorite one - PostgreSQL. I will explain in detail how new ansible DB role is conceived. Also you will learn a couple of useful concepts about adding new deb repository.

Here is GitHub repository url where you can get ansible playbook.

Command to create interactively a database user is:

$ sudo -u postgres createuser --interactive

To see if PostgreSQL Server version 12 is up and running, on Ubuntu system use:

$ sudo systemctl status postgresql@12-main.service

Command to create a database instance owned by userx

sudo -u postgres createdb -O  userx dbname

To change manually some postgres user's password use following command:

$ sudo -u postgres psql
psql>ALTER USER <username> WITH PASSWORD '<password>';

And finally to list all users and databases which are currently in database server, use psql -l:

$ sudo -u postgres psql -l
Wow, no similar lessons found! You have just found a very unique lesson!