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

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
[MongoDB]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

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.

how to install mongodb 4.2 in centos 7install mongodb 4.2 on fedoramongodb 4.2
Comments (0)
Add Comment