How To Create Database In MongoDB 4.2 On CentOS / Redhat 7

Mongodb’s crossed-platform document oriented database program. I have installed Mongodb 4.2 version on Linux Server using the repository from mongodb site. Let’s see how to create database in mongodb 4.2.

Check Out : Installation Of MongoDB Database Server

Mongodb database also known as NoSQL database program and Mongodb uses json like documents with schema.

Step 1 : Login mongodb console using below command


Check all database,

show dbs

Step 2 : Create database, this will create ‘test’ database if not present and you can also use the same command to switch the database.

use test

As you can see ‘test’ database is not present. This will not appear until you don’t write at-least one document in this database.

You can check your current database where you’re by ‘db’.

Step 3 : Now you need to add at-least one data in ‘test’ database.

db.user.insert({name: “deloa”, age: 20})

Step 4 : Check your database will be appeared here

show dbs

if you want to drop this database, So we can’t specify the database name to drop it. What we can do. Use the database you want to drop and run the below command.


YouTube Link : Database Create In Mongodb 4.2

You’re done

Leave a Reply

Notify of