We will see How to Install MongoDB on CentOS 7 Linux Step by Step, MongoDB is a No-SQL database that is written in C++, It uses a JSON-like structure. MongoDB is a cross-platform and document-oriented database.
The initial release of the MongoDB was on 11 February 2009, you can find the main website of the MongoDB as well the git repository
So let’s install MongoDB on CentOS 7 Linux Step by Step guide also, find the cheat sheet below for Quick Installation.
After come and read the whole post to get detailed knowledge about the Installation of MongoDB.
Cheat Sheet of How to Install MongoDB on CentOS 7.
STEP 1: Add Repository into the CentOS Server.
Create a file with the name “mongo-4.4.repo” into the “/etc/yum.repos.d/” directory or you can use any editor of your choice and paste the below lines.
[mongodb-org-4.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
STEP 2: Install MongoDB 4.4 on CentOS 7 Linux.
$ sudo yum install mongodb-org -y
STEP 3: Start the Service of MongoDB Server on CentOS.
$ sudo systemctl start mongod
Check the Status:
$ sudo systemctl status mongod
Restart the service:
$ sudo systemctl restart mongod
Stop the service:
$ sudo systemctl stop mongod
Start the service at the time of Booting:
$ sudo systemctl enable mongod
STEP 4: Use “mongo” command in the terminal or BASH to connect with MongoDB.
$ mongo
STEP 1: Add MongoDB Repository into the CentOS 7 Server to Install.
Create a file with the name “mongo-4.4.repo” into the “/etc/yum.repos.d/” the directory or you can use any editor of your choice and paste the below lines.

[mongodb-org-4.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
So, after that save and quit the file but if you want to install version 4.0 into the CentOS Server then replace the configuration like below.
[mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
So we have made 3 changes to our repo file,
1. we have to change the name. — [mongodb-org-4.0]
2. we have to change baseurl — baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
3. we have to change the gpgkey version — gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
As you will notice we have just made the changes in the version of the MongoDB.
STEP 2: Install MongoDB 4.4 on CentOS 7.
So first, we will update the repository of MongoDB now we will install the MongoDB service.
$ sudo yum install mongodb-org -y
STEP 3: Start the Service of MongoDB on CentOS
So after the successful installation, we will start the services of the MongoDB server by “systemctl command”
$ sudo systemctl start mongod
So to check the Status of the MongoDB service use status in the place of start
$ sudo systemctl status mongod
If we have to restart the service of MongoDB in the CentOS server then we will use the below command.
$ sudo systemctl restart mongod
If we have to stop the service of MongoDB then use the stop option
$ sudo systemctl stop mongod
What if we want to start the service when my server got rebooted.
$ sudo systemctl enable mongod
So we have successfully installed the MongoDB server and use “mongo” in terminal or bash to check are you able to connect.

$ mongo
Allow MongoDB to connect from Remote IP
If you have to connect your MongoDB server from a Remote IP, then you have to make some configuration changes and restart the service of MongoDB.
So first we will look into the configuration file of the MongoDB server “/etc/mongod.conf”
# network interfaces net: port: 27017 bindIp: 127.0.0.1
So you will find that the bind IP is 127.0.0.1 which will allow to local only, and we want to allow to any remote IP then change the bind IP to “0.0.0.0”
# network interfaces net: port: 27017 bindIp: 0.0.0.0
After we have to restart the MongoDB service so that we can access port 27017 to any remote IP.
$ sudo systemctl restart mongod
If still not working then check your firewall, whether the firewall is active or not.
Now we have two option can inactive the firewall or you can allow the 27107 port number from the CentOS 7 Server.
If you are facing any issues while installing MongoDB let us know, we will help you out.
Thanks to reading the article, learn how to install MongoDB on Ubuntu, Install MongoDB on Ubuntu 20.04, Install MongoDB on Windows 10, Install MongoDB on AWS Ec2.
Install MongoDB centos 8, Install MongoDB centos 7, Install MongoDB centos 7.5, Install MongoDB on centos 7 step by step.