How to Install MongoDB 4.0 on Centos 7/RHEL 7

by Sandeep B.

In this tutorial we’ll  Install MongoDB 4.0 on Centos 7/RHEL 7 linux OS. MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. it is recommended for business and enterprise uses although you can also use in your production environment. It is a NoSQL database. MongoDB 4.0 supports multi-document ACID transactions.

Step 1

Adding MongoDB 4.0 Repository  :

Create repo file :

yum install nano -y
nano /etc/yum.repos.d/mongodb4.repo

Now add this lines to mongodb4.repo :

name=MongoDB Repository

Save and exit

Step 2

Installing MongoDB 4.0 :

yum install -y mongodb-org

If you’ve enabled selinux you need to run this command in order to give access :

semanage port -a -t mongod_port_t -p tcp 27017

*use this command if you’re using enforcing mode

Step 3

Verify the installation and enable startup :

Start MongoDB Service :

service mongod start

To restart and stop MongoDB Service :

service mongod restart
service mongod stop

you need to run this command from command line in order to access mongo db CLI interface :


To enable mogodb start automatically during os boot :

systemctl enable mongod

If this post helps you in any way please consider a donation

Donate with PayPal :


You may also like

Leave a Comment