MongoDB is a NoSQL database that has fully flexible index support and a rich queries database.
This document explains how to install MongoDB (as root/sudo).
Step 1 – Setup Apt Repository
First of all, import GPK key for the MongoDB apt repository on your system using the following command. This is required to test packages before installation
After adding required APT repositories, use the following commands to install MongoDB on your systems. It will also install all dependent packages required for MongoDB.
1
sudo apt update
2
sudo apt install -y mongodb
Copied!
If you want to install a specific version of MongoDB, define the version number as follows:
Important: Some versions have the service name as mongod and some have mongodb. If you get an error with the above command, use sudo service mongodb status instead.
Step 5 - Test MongoDB
Also, connect MongoDB using the command line and execute some test commands for checking proper working.