MongoDB

How to install MongoDB on Ubuntu 20.04

How to install MongoDB on Ubuntu 20.04
MongoDB is one of the most popular NoSQL databases, it is open source and freely available to download. It stores data in the form of flexible documents like JSON rather than the usual table style method found in SQL databases. MongoDB is used to store and work on data without the use of schema or ordering patterns. The MongoDB NoSQL database is widely used in web applications because it has easier integration with various programming languages.

In this tutorial guide, I will show you how to install, run, and uninstall MongoDB on ubuntu 20.04.

Install MongoDB NoSQL Database:

MongoDB is very easy to install, and it is present in Ubuntu 20.04 software repository.

Step 1:

As always, first, update and upgrade your APT.

$ sudo apt update

$ sudo apt upgrade

Step 2:

Now download and install it via the following terminal command. It requires root privileges so type sudo with command.

$ sudo apt install mongodb

Step 3:

MongoDB is installed on your system now and it starts automatically after installation. To check the status of this database, type the following command in the terminal window.

$ sudo systemctl status mongodb

Run MongoDB service:

MongoDB service needs the systemctl command to modify its state. It requires root privileges so sudo must be used before every command.

MongoDB status checking:

The following command is used to check the status.

$ sudo systemctl status mongodb

MongoDB starts command:

MongoDB can be started through the following command.

$ sudo systemctl start mongodb

MongoDB stop command:

MongoDB can be stopped with this command.

$ sudo systemctl stop mongodb

MongoDB restart command:

In case you run into some errors and restart is compulsory then type the following command.

$ sudo systemctl restart mongodb

Enable option MongoDB when the system boots:

$ sudo systemctl enable mongodb

Disable option for MongoDB when the system boots:

$ sudo systemctl disable mongodb

By default, MongoDB is enabled after installation.

Starting MongoDB shell:

To work on the databases, you can open the “mongo shell” with the following terminal command.

$ sudo mongo

Uninstall MongoDB:

In case you do not need MongoDB and want to uninstall it then enter these three commands.

$ sudo systemctl stop mongodb

This command will stop the service.

$ sudo apt purge mongodb

$ sudo apt autoremove

These two commands will uninstall the MongoDB database. This will wipe out all the database files so make sure that you have backed up your necessary files.

Conclusion:

Wasn't this an easy tutorial for installing MongoDB on ubuntu? MongoDB is a popular database for creating NoSQL documents.

Kuinka näyttää FPS-laskuri Linux-peleissä
Linux-pelaaminen sai suuren työn, kun Valve ilmoitti Linux-tuesta Steam-asiakkaalle ja heidän peleilleen vuonna 2012. Siitä lähtien monet AAA- ja indi...
How to download and Play Sid Meier's Civilization VI on Linux
Introduction to the game Civilization 6 is a modern take on the classic concept introduced in the series of the Age of Empires games. The idea was fai...
How to Install and Play Doom on Linux
Introduction to Doom The Doom Series originated in the 90s after the release of the original Doom. It was an instant hit and from that time onwards th...