Celebrate Our 22nd Anniversary with Huge Savings! Up to 70% Off

How to Install MongoDB Version 4.0 on CentOS 7?

MongoDB is an open-source and free database service that is a NoSQL Database and is different from other databases like MSSQL and MySQL. 

There is no requirement for a predefined schema and data structure as it will be changed. Data will be stored in JSON-like documents in MongoDB.

(We assume you are logged in with root or sudo user.)

 

Following are the steps to install MongoDB 4 on CentOS 7 – 

1. Add MongoDB repository to mongodb-org.repo inside the /etc/yum.repos.d/ directory using command : vi /etc/yum.repos.d/mongodb-org.repo

2. Enter the below details in mongodb-org.repo

[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

3. Once the repository is enabled, install MongoDB using the Yum command as below.

# sudo yum install mongodb-org      

You need to press y when MongoDB asks for the GPG Key during installation.

4. MongoDB will install the packages given below as per the screen capture – 

mongodb-org-mongos.x86_64 0:4.0.14-1.el6                                
mongodb-org-server.x86_64 0:4.0.14-1.el6                                      
mongodb-org-shell.x86_64 0:4.0.14-1.el6                                       
mongodb-org-tools.x86_64 0:4.0.14-1.el6

          

5. Start MongoDB and enable it to start on boot.

sudo systemctl start mongod
sudo systemctl enable mongod

6. You can use the Mongo command to verify the installation MongoDB version.

mongo

 


Was this answer helpful?

« Back

chat