Installing MongoDB Using Official Repository
Step 1: Configure package management system
Create a /etc/yum.repos.d/mongodb-org-7.0.repo file so that you can install MongoDB directly using yum.
To do that we will use nano editor.
sudo nano /etc/yum.repos.d/mongodb-org-7.0.repo
Now paste the following into the terminal (use Ctrl+Shift+V to paste inside of a terminal).
[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/7.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-7.0.asc
Once pasted, press Ctrl + s to save and Ctrl + x to exit the editor.
Step 2: Install mongodb
Now, we can use yum package manager to install yum directly to our system.
sudo yum install -y mongodb-org mongodb-org-database mongodb-org-server mongodb-mongosh-shared-openssl3 mongodb-org-mongos mongodb-org-tools
How to Install MongoDB on CentOS?
MongoDB is a flexible, powerful, and super-fast database management system. Unlike those old-school databases with strict rules, MongoDB lets you store your data in flexible documents, similar to how you organize things in JSON. This means you can easily add new information or change things up without much hassle.
In this article, we will install MongoDB on CentOS using two methods.
Table of Content
- How to Install MongoDB on CentOS?
- Method 1: Installing MongoDB Using RPM Package
- Method 2: Installing MongoDB Using Official Repository
- Starting MongoDB Services After Installation
- Running MongoDB with MongoDB Shell
- How to Verify MongoDB Installation on CentOS?
- How to Uninstall MongoDB?