How to install MongoDB on Ubuntu 20.04

In this article, We will learn how to install MongoDB on Ubuntu 20.04 LTS step by step.

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.

Steps to Install MongoDB on Ubuntu 20.04:

1. Import the public key used by the package management system.

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

How to install MongoDB on Ubuntu 20.04

2. Create a /etc/apt/sources.list.d/mongodb-enterprise.list file for MongoDB.

echo "deb [ arch=amd64,arm64,s390x ] http://repo.mongodb.com/apt/ubuntu focal/mongodb-enterprise/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list

3. Now, reload the local package database using below command.

sudo apt-get update

4. Now, install MongoDB enterprise edition on Ubuntu 20.04 LTS using below command.

sudo apt-get install mongodb-enterprise

Type ‘Y’ and enter to continue to download and install.

5. MongoDB 4.4.2 installed successfully.

MongoDB Post Installation Steps:

1. Lets start MongoDB using below command.

mongod is the service name for MongoDB Server.

sudo systemctl start mongod

2. Lets verify the mongodb server status.

sudo systemctl status mongod

3. Enable MongoDB to start following a system reboot by issuing the following command:

sudo systemctl enable mongod

4. Connect to MongoDB using mongo shell. Just type mongo from your terminal and press enter. Then, you will connect to MongoDB server.

MongoDB shell version v4.4.2 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("ee5c6c7b-c57b-469e-bf19-98c8b352bbbf") } MongoDB server version: 4.4.2 Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see https://docs.mongodb.com/ Questions? Try the MongoDB Developer Community Forums https://community.mongodb.com --- The server generated these startup warnings when booting: 2020-12-21T12:40:45.133+05:30: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem 2020-12-21T12:40:46.355+05:30: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted --- MongoDB Enterprise >

Leave a Reply

Your email address will not be published. Required fields are marked *