This article covers how to #install / #uninstall MongoDB on your Debian system. You have also learned how to manage MongoDB services.
MongoDB is an opensource, cross-platform NoSQL database server.
In MongoDB, data is stored in flexible, JSON-like documents where fields can vary from document to document.
It does not require a predefined schema, and data structure can be changed over time.
To install MongoDB on #Debian:
Perform the following steps as root or user with sudo privileges to install MongoDB on a Debian system.
- Install the packages required for adding a new repository:
$ sudo apt install dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl
- Add the MongoDB GPG key to your system:
$ curl -fsSL https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
- Enable the MongoDB repository:
$ sudo add-apt-repository 'deb https://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main'
- Packages with older versions of MongoDB are not available for Debian 10.
Update the packages list and install the mongodb-org meta-package:
$ sudo apt update
$sudo apt install mongodb-org
The following packages will be installed on the system as a part of the mongodb-org package:
mongodb-org-server - The mongod daemon and corresponding init scripts and configurations.
mongodb-org-mongos - The mongos daemon.
mongodb-org-tools - Contains several MongoDB tools for importing and exporting data, statistics, as well as other utilities.
To Start the #MongoDB service and enable it to start on boot:
sudo systemctl enable mongod --now