May 28, 2023

How to Install MongoDB 4.2 on CentOS/RHEL 8/7/6

What Is MongoDB?

MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). Click here for more details.

Step 1: Add MongoDB Yum Repository

The MongoDB repository doesn’t come by default with CentOS repositories. However, MongoDB maintains a dedicated repository. Let’s add it to our server.

With vi editor, we will create a .repo file for yum, the package management utility for CentOS:

# vi /etc/yum.repos.d/mongodb.repo
name=MongoDB Repository

Step 2 – Install MongoDB Server

Now, we can install the mongodb-org package from the third-party repository using the yum utility.

# sudo yum install mongodb-org

Step 3 – Start MongoDB Service

Use the following command start, restart the mongodb services.

# systemctl start mongod.service                     # For CentOS 8/7 
# service mongod restart                             # For CentOS 6 

# systemctl enable mongod.service                    # For CentOS 8/7 
# chkconfig mongod on                                # For CentOS 6 

Step 4 – Check MongoDB Version

Use the following command to check the mongodb version.

# mongod --version

Congratulation, Now you have successfully installed mongodb on your server.

Vedant Singh

Currently I'm working as an Implementation Engineer, Started my career as an System Administrator - Linux. Additionally he loves to explore new technologies and research about new open-source software that ease the development cycle.

View all posts by Vedant Singh →

Leave a Reply

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


Ad Blocker Detected!

We've noticed that you are using an ad blocker. Advertising helps fund our server cost and keep it truly independent. It helps to build our content creator team. So please disable your ad blocker, and help us to keep providing you with free- great content - for free. Thank you for your support.