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 a database in MongoDB 4.2.

Check Out: Installation Of MongoDB Database Server

MongoDB database is also known as the NoSQL database program and
MongoDB uses JSON like documents with the schema.

Step 1: Login MongoDB console using below command


Check all database,

show dbs

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

use test

As you can see the ‘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 the ‘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