
A Comprehensive Guide to Installing MongoDB 4 on Fedora and CentOS
MongoDB is a leading NoSQL database renowned for its flexibility, scalability, and powerful feature set. Whether you’re developing a modern web application, managing big data, or simply learning a new database technology, getting MongoDB running on your system is the first critical step.
This guide provides a clear, step-by-step process for installing MongoDB 4 on two popular Red Hat-based Linux distributions: Fedora and CentOS. By following these instructions, you’ll have a fully functional and secure MongoDB instance ready for your projects.
Prerequisites
Before we begin, ensure you have the following:
- A running instance of Fedora or CentOS.
- Access to a user account with
sudo
or root privileges. - A stable internet connection to download the necessary packages.
Step 1: Add the Official MongoDB Repository
To ensure you install a trusted and stable version of MongoDB, it’s essential to use the official repository. This prevents compatibility issues and provides access to the latest security patches and updates.
We will create a repository file that tells your system’s package manager (dnf
for Fedora, yum
for CentOS) where to find the MongoDB packages.
Open your terminal and create a new repository file using a text editor like
nano
orvi
:sudo nano /etc/yum.repos.d/mongodb-org-4.4.repo
Copy and paste the following configuration into the file. This configuration works for both CentOS and Fedora.
[mongodb-org-4.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
name
: A descriptive name for the repository.baseurl
: The location of the packages. The$releasever
variable automatically detects your OS version.gpgcheck=1
: Enables GPG key verification to ensure package integrity.enabled=1
: Activates the repository.gpgkey
: The URL for the GPG key used to sign the packages.
Save the file and exit the text editor. (In
nano
, pressCTRL + X
, thenY
, thenEnter
).
The first and most important step is to configure the official MongoDB repository, which guarantees
Source: https://kifarunix.com/install-mongodb-4-on-fedora-30-29-centos-7/