How to Install MongoDB on Ubuntu 18.04

0
799

Install MongoDB on Ubuntu 18.04 LTS Server

Before starting the installation of MongoDB on Ubuntu. Let’s have a description about MongoDB. MongoDB a type of database in which we deal with document i.e. database which is more scalable and flexible with the queries that you run to get results on specific conditions. MongoDB is a very fast and more easy to use than traditional database.

In this article we will learn how to install and manage MongoDb to use in our Ubuntu 18.04 server. So let’s start by the following steps.

STEP1:  ADDING MONGODB PACKAGE REPOSITORY TO UBUNTU.

The first step for installing MongoDB on Ubuntu is to add repository files of MongoDB. Actually MongoDB is already in the repository in the Ubuntu by default. But the version in the repositories might not be the latest to your requirements. Therefore, to get the latest version of MongoDB, you have to add its repository in the Ubuntu. Following is the process to add official repository key by command.

Command:  

After adding repository key into Ubuntu server, then you have to add the repository to your own system. For this do follow the command mentioned below:

Command:

 

Step 2: Install MongoDB on Ubuntu 18.04

After adding repositories, you have to install MongoDB on Ubuntu, for this purpose follow the instructions by typing the following commands. This will install MongoDB completely on your Ubuntu and you will get access to use MongoDB.

Command:

Step 3: Start MongoDB

After the successful installation of MongoDB over Ubuntu, you can now start MongoDB and manage its components. To verify whether MongoDB is running and active, run following command.

Command:

 

To start MongoDB type

 

Step 4: Configure Mongo or Open Mongo Shell

When MongoDB is installed, then you can configure database username and passwords for further use. But before configuring username and passwords MongoDB shell has to be in running state or you have to open its shell. So for opening shell run or type the following command.

Command: 

 

 

Step 5:  Use database Admin Mode

After opening the shell, you may need to move or switch to the database admin where you can create users and passwords respectively. For this purpose, just use the command mentioned below.

Command: 

 

Step 6:  Create root user for database

Once you are in the database admin mode, now you can create root user for database. This root user will have permission and roles as an admin to the database. To create root user type following command using your own username and password.

Command:

 

Step 7:  MongoDB authentication

When you done with creating your root user, then after exiting the MongoDB, you can now authenticate this. To authenticate MongoDb use the following command.

Command: 

 

 

Step 8: Connect MongoDB after restarting

After complete authentication and restarting of MongoDB, now you have to connect again with the details of username and password, you have created earlier in the creating root user step. Step 8: to connect run the following command.

Command:

to connect MongoDB

to restart MongoDB*

Conclusion:

After following all the guideline, you are now able to install MongoDb repositories in Ubuntu as well as in your system. And using MongoDb to manage and authenticate as well as creating root user. However, you should follow the same procedure to make it accurate. If you face any problem, then leave a message or comment. We will help you in every matter.

Spread the love
  • 8
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here