How to Install MongoDB Community Edition 6.0 on Red Hat or CentOS?

MongoDB Community is the free edition of MongoDB which is a well-known non-relational database. It supports numerous operating systems, such as Ubuntu, Debian, Windows, MacOS, Red Hat, and CentOS. It can be installed on Red Hat or CentOS to act as a database server for modern applications. This blog has a procedural guide to install the MongoDB Community Edition 6.0 on Red Hat or CentOS operating systems.

How to Install MongoDB Community Edition 6.0 on Red Hat or CentOS?

To install the latest MongoDB Community Edition on the Red Hat or CentOS operating system, follow the steps mentioned below. The commands are the same for both OS, however, this blog will show the outputs of CentOS:

Step 1: Add MongoDB Repository on Red Hat or CentOS

As the latest stable edition is MongoDB Community 6.0, so let us create a MongoDB repository configuration file with the name “mongodb-org-6.0.repo” using the nano editor:

sudo nano /etc/yum.repos.d/mongodb-org-6.0.repo


The terminal prompts the password and opens a new file.

Copy and paste this code into the newly created configuration file of the MongoDB repository:

name=MongoDB Repository


Save the code and exit the nano editor by pressing the “CTRL + X” keys.

Step 2: Install the Latest Edition of MongoDB Community

To install the latest MongoDB Community Edition, execute the command given below:

sudo yum install -y mongodb-org


The installation will consume some time.

Wait for the process installation process to complete:

The latest MongoDB Community Edition is installed successfully.

Sometimes the user wants to install any specific version of MongoDB Community, such as “5.0.17”, “4.4.21” and “6.0.5”. For that purpose, enlist each product with the version number in the command as shown:

sudo yum install -y mongodb-org-6.0.5 mongodb-org-database-6.0.5 mongodb-org-server-6.0.5 mongodb-org-mongos-6.0.5 mongodb-org-tools-6.0.5


The specified edition of MongoDB Community is installed successfully.

Step 3: Verify the Installation of MongoDB Community Edition

To verify whether the installation is complete or not, execute this command to see the details of the installed MongoDB Server:

mongod --version


The output returned the details of the latest MongoDB Server along with its version.

Step 4: Manage the MongoDB Server Services

The commands are listed below to manage the MongoDB Server services in Red Hat or CentOS.

Start the service of MongoDB server by using this command:

sudo systemctl start mongod

To see the status of the MongoDB server service, utilize this command:

sudo systemctl status mongod


The output shows that the MongoDB server started successfully.

If any error prompts and the server does not start, run this command:

sudo systemctl daemon-reload

After running the reload command, enable the server by using the given command:

sudo systemctl enable mongod

Run the status command to verify the status of the server.


Sometimes, the user needs to stop the services manually. For that purpose, run this command and the status command to see its effect:

sudo systemctl stop mongod


The output displays that the MongoDB server service stopped successfully.

To restart this service, execute the command mentioned below:

sudo systemctl restart mongod


The MongoDB Server Service is running.


To install the latest MongoDB Community Edition 6.0 on Red Hat or CentOS, create a MongoDB repository configuration file and paste the code provided in the blog to configure the MongoDB repository. After that, install the latest edition using the “sudo yum install -y mongodb-org” command. Once the MongoDB Community edition is installed, manage the MongoDB server services using “systemctl” commands.

About the author

Nimrah Ch

I’m a technical writer with a Bachelor's in Software Engineering and Certification in Cyber Security. Through my research and writing, I strive to provide readers with in-depth, informative articles that can help them make informed decisions about their technological needs.