# How to Install MongoDB Community Edition in Redhat Linux

This article will help you to install the latest version of MongoDB (8.0.6) in the Oracle Linux Server/Redhat Linux Server

### **Step 1: Create MongoDB Repository File**

The first step is to create a MongoDB Repository File. The content of this file will vary depending upon which version of MongoDB you are going to install. To get the exact content of your version, you can refer to the MongoDB Installation Guide. Since, I am installing the latest MongoDB version such as 8.0.6, I got the following content from the MongoDB Installation Guide.

**MongoDB Installation Guide Link:**  
https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/

```plaintext
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc
```

**The repository file name for MongoDB 8.0.6 is:** mongodb-org-8.0.repo

So, create a empty file called “mongodb-org-8.0.repo” in the location “/etc/yum.repos.d/”. Then, open this file and add the above lines of contents in this file.

**$ sudo vi /etc/yum.repos.d/mongodb-org-8.0.repo  
$ cat /etc/yum.repos.d/mongodb-org-8.0.repo**

```plaintext
sudo vi /etc/yum.repos.d/mongodb-org-8.0.repo
cat /etc/yum.repos.d/mongodb-org-8.0.repo
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742622308550/dba373a4-cd1c-4497-9147-6a45d252a603.png align="center")

### **Step 2: Install the MongoDB Software**

Install the MongoDB software using the dnf or yum command.

**$ sudo dnf install mongodb-org -y**

```plaintext
sudo dnf install mongodb-org -y
```

The above command will install the latest version of MongoDB. The current latest version is 8.0.6 as of writing this article date. The screenshot of the installation step is shown below.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742622647144/e81be574-5dda-4d42-a5a1-1696523872ed.png align="center")

Once the MongoDB is installed, it will also create an OS user called “mongod”. To validate whether this user is created or not, you can run the following command. This will show the username if it has created successfully.

**$ sudo cat /etc/passwd|grep -i mongod**

```plaintext
sudo cat /etc/passwd|grep -i mongod
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742622849849/27850bb0-c783-440e-a51e-3ec7139eb177.png align="center")

### **Step 3: Start the MongoDB Service/Process**

**$ sudo systemctl start mongod  
$ sudo systemctl enable mongod  
$ sudo systemctl status mongod**

```plaintext
sudo systemctl start mongod 
sudo systemctl enable mongod 
sudo systemctl status mongod
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742622957200/a7167c34-0a66-4ee4-9762-e7fb63ff05f3.png align="center")

### **Step 4: Verify the MongoDB Version**

**$ sudo mongod --version**

```plaintext
sudo mongod --version
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1742623105050/6bfee29f-0894-4250-b4b2-2530b339796c.png align="center")

You can now start working with the MongoDB databases. For more details on how to work with MongoDB databases, please read my other article here.

---

Thanks for reading this article. Hope it helped you to progress your work!!
