MongoDB 8 Installation Guide for CentOS 8
MongoDB 8 Installation Guide for CentOS 8
Install MongoDB 8 on CentOS 8
This guide provides the correct steps to install MongoDB 8.0 on CentOS 8 / RHEL 8 / Rocky Linux 8 / AlmaLinux 8.
1. Add MongoDB YUM Repository
Create a repo file:
sudo nano /etc/yum.repos.d/mongodb-org-8.0.repo
Paste:
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-8.0.asc
2. Install MongoDB 8.0
sudo dnf clean all
sudo dnf install -y mongodb-org
3. Start & Enable MongoDB
sudo systemctl start mongod
sudo systemctl enable mongod
sudo systemctl status mongod
4. Verify Installation
mongod --version
mongosh
5. (Optional) Open Firewall Port
sudo firewall-cmd --add-port=27017/tcp --permanent
sudo firewall-cmd --reload
6. SELinux Fix (if MongoDB fails)
Temporarily:
sudo setenforce 0
Permanently:
Edit /etc/selinux/config:
SELINUX=permissive
7. Fix CentOS 8 Repo Metadata Issue
sudo dnf upgrade --refresh
sudo dnf config-manager --set-enabled powertools
Done!
MongoDB 8 is now installed successfully.