How to install MongoDB on CentOS

Table of Contents

How to install MongoDB on CentOS



Document-oriented databases like MongoDB use dynamic schemas to store data in JSON-like documents. In other words, you don’t have to worry about the structure of your database, such as how many fields might there be or the type of fields you might be able to incorporate. As with MongoDB, JSON objects have an equivalent format. 


Let’s take a look at how to deploy MongoDB on CentOS, Your system must first be updated first.


Let’s start,




Install MongoDB Community Edition



We use the latest version of MongoDB here. You can adjust this as needed. Use yum to install MongoDB.,



  • Create the /etc/yum.repos.d/mongodb-org-4.4.repo file for MongoDB.
nano /etc/yum.repos.d/mongodb-org-4.4.repo


  • Paste the following into the editor:


name=MongoDB Repository


  • Save and exit the file. Next install the latest stable version of MongoDB


sudo yum install -y mongodb-org



Configure MongoDB


  • Start MongoDB.
$ systemctl start mongod.service
$ systemctl enable mongod.service


  • Establish a connection to MongoDB by using this command,


The default security settings in MongoDB are insecure. Check out our guide to secure MongoDB



Get the most out of learning with

Make a Comment
Share on
VPSie Cloud service

Fast and Secure Cloud VPS Service

For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.