Introduction
MongoDB is an open-source document, NoSQL, or non-relational database it stores data in the JSON format MongoDB is written in C++ and has its own query language called JSON. This makes it easy to manipulate data in the database. It also supports indexing and geospatial queries.
This article will explain how to install MongoDB on Ubuntu 20.04 OS.
Installing MongoDB on Ubuntu:
- Run the below command on the terminal to add the public GPG repository key for the latest stable version of MongoDB.
This command will return$ curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
OK
if the key was added successfully. - Next, add the repository source for Ubuntu 20.04 using the following command.
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
- Update the apt repository and then install the MongoDB server packages.
$ sudo apt update
$ sudo apt install mongodb-org
Start MongoDB service:
- Start the MongoDB service using the following command.
$ sudo systemctl start mongod.service
- Run the following command to check and verify the status of the MongoDB service.
$ sudo systemctl status mongod
- Enable the MongoDB service on boot with the following command.
$ sudo systemctl enable mongod