How to Download and Install MongoDB on Fedora 40
Welcome to this guide on how to download and install MongoDB on the latest Fedora 40 release. MongoDB is a popular NoSQL database that…
How to Download and Install MongoDB on Fedora 40
Welcome to this guide on how to download and install MongoDB on the latest Fedora 40 release. MongoDB is a popular NoSQL database that provides high performance, high availability, and easy scalability. Whether you’re a developer, system administrator, or just curious about databases, this guide will walk you through the steps to get MongoDB up and running on your Fedora system.
Prerequisites
Before we begin, ensure your system meets the following prerequisites:
- A machine running Fedora 40.
- Sudo or root access to your system.
- A stable internet connection.
Step 1: Update Your System
First, let’s make sure your system is up to date. Open your terminal and run the following commands:
sudo dnf update
Step 2: Import the MongoDB GPG Key
MongoDB signs its packages with a GPG key to ensure package integrity. Import the MongoDB GPG key with the following command:
sudo rpm --import https://www.mongodb.org/static/pgp/server-7.0.asc
Step 3: Add MongoDB Repository
Next, add the MongoDB repository to your system. Create a new repository file:
sudo nano /etc/yum.repos.d/mongodb-org-7.0.repo
Add the following content to the file:
[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://www.mongodb.org/static/pgp/server-7.0.asc
Save and close the file by pressing Ctrl+S, then Ctrl+X.


Step 4: Install MongoDB
Now, install the MongoDB packages by running:
sudo dnf install mongodb-org mongodb-org-server
If you are facing permission error in /etc/group, the most probable reason is that SELinux (Security-Enhanced Linux) is enabled, so it might be preventing access.

You can temporarily disable SELinux to allow access to /etc/group using the below command, after disabling run the install commands again. Note that this command switches SELinux to the Disabled mode. It doesn’t change the permanent SELinux configuration. When you reboot your Fedora system, SELinux will automatically return to the mode specified in your configuration file (/etc/selinux/config).
sudo setenforce 0
Step 5: Start and Enable MongoDB Service
Once the installation is complete, start the MongoDB service and enable it to start on boot:
sudo systemctl enable mongod.service
sudo systemctl start mongod.service
Step 6: Verify Installation
To verify that MongoDB is running correctly, check its status with:
sudo systemctl status mongod.service
You should see an active (running) status.

Step 7: Access MongoDB Shell
You can access the MongoDB shell by running:
mongosh
This will open the MongoDB shell where you can interact with your MongoDB instance.
You might encounter an error regarding OpenSSL, similar to what is shown here in the image below.

Run the below commands to fix that. After these commands are run you should be able to enter the mongosh shell.
sudo dnf remove mongodb-mongosh
sudo dnf install mongodb-mongosh-shared-openssl3
sudo dnf install mongodb-org

Step 8: Testing mongosh shell
Insert a new document into the sample_mflix.movies collection:
use sample_mflix
db.movies.insertOne(
{
title: "The Favourite",
genres: [ "Drama", "History" ],
runtime: 121,
rated: "R",
year: 2018,
directors: [ "Yorgos Lanthimos" ],
cast: [ "Olivia Colman", "Emma Stone", "Rachel Weisz" ],
type: "movie"
}
)
insertOne() returns a document that includes the newly inserted document’s _id field value.
db.movies.find({ title: “The Favourite” }): Queries the movies collection to find documents where the title field matches “The Favourite”. This retrieves the newly inserted document.
db.movies.find( { title: "The Favourite" } )

You can check out more of these operations in the MongodbShell Documentation.
Conclusion
Congratulations! You have successfully installed MongoDB on Fedora 40. You can now start exploring MongoDB and building applications that leverage its powerful features. If you encounter any issues or have questions, refer to the official MongoDB installation documentation for more detailed information.
메타데이터
- post_id
- 2db148a7c2f0
- slug
- how-to-download-and-install-mongodb-on-fedora-40-2db148a7c2f0
- url
- https://medium.com/@nkav2447/how-to-download-and-install-mongodb-on-fedora-40-2db148a7c2f0
- canonical_url
- https://medium.com/@nkav2447/how-to-download-and-install-mongodb-on-fedora-40-2db148a7c2f0
- author_url
- https://medium.com/@nkav2447
- status
- ok
- fetched_at
- 2026-06-27 18:20:27