How To Install MongoDB on CentOS

MongoDB is a general-purpose, distributed, document-based database built for modern app developers and the cloud era. It is the leading NoSQL database most commonly used in modern web applications. This article will describe how to install this Database on a Linux distribution such as CentOS. The guide focuses on the following distribution versions: RHEL / CentOS 8, RHEL / CentOS 7 and older – RHEL / CentOS 6

Install MongoDB Community Edition

Install MongoDB Database using CentOS Package Installation Manager – yum. First, you need to create a file /etc/yum.repos.d/mongodb-org-4.4.repo for this database

# nano /etc/yum.repos.d/mongodb-org-4.4.repo

Then paste into your text editor what is described below:

name=MongoDB Repository

Save this and then you can close your text editor. After that, if you want to install the latest, stable and current version of MongoDB, you need to enter the following:

# sudo yum install -y mongodb-org

Configuring MongoDB

At this stage, the installation of this Database is completed. Now you need to configure it. To do this, you must first start MongoDB

# systemctl start mongod.service
# systemctl enable mongod.service

Next, connect to MongoDB

# mongo

MongoDB is insecure by default. You can follow this link to configure security and authentication of this Database.

If you need to install a specific version or prevent automatic updates, you can see the MongoDB documentation.

Was this article helpful?

Related Articles