Skip to main content

Command Palette

Search for a command to run...

Day 17/100 of DevOps

Day 17: Set Up PostgreSQL Database for the Nautilus App

Published
2 min read

Task: PostgreSQL database server is already installed on the Nautilus database server.

a. Create a database user kodekloud_cap and set its password to YchZHRcLkL.

b. Create a database kodekloud_db6 and grant full permissions to user kodekloud_cap on this database.

Note: Please do not try to restart PostgreSQL server service.

This challenge focuses on setting up a PostgreSQL database, specifically creating a dedicated user, a new database, and granting that user full permissions, preparing the environment for an application without restarting the service.

Step by Step Process:

  1. Login to the Database server

    ssh peter@stdb01

  2. Switch to the postgres system user

    On most Linux servers, PostgreSQL is managed by the postgres OS user. Run:

    sudo su - postgres

  3. Access the PostgreSQL Interactive Shell

    psql

    This gave me access to the PostgreSQL command interface where I could safely run SQL statements.

  4. Create the User

    I created the user and assigned the password:

    postgres=# CREATE USER kodekloud_cap WITH PASSWORD 'YchZHRcLkL';

  5. Create the Database

    postgres=# CREATE DATABASE kodekloud_db6;

  6. Grant Privileges

    Granting full access to the user on the newly created database:

    postgres=# GRANT ALL PRIVILEGES ON DATABASE kodekloud_db6 TO kodekloud_cap

  7. Exit PostgreSQL and Postgres User

    exit

    And the database environment was fully set up, without touching the service status or configuration files.