How to Install MongoDB 5 on Fedora 35
MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL).
Unlike relational databases, it doesn't consist of tables and rows, but it’s built on an architecture of collections and documents. Documents comprise sets of key-value pairs and are the basic unit of data in it. Collections contain sets of documents and function as the equivalent of relational database tables.
There are three editions of MongoDB available to date:
- MongoDB Community Server
- MongoDB Enterprise Server
- MongoDB Atlas
For general users, the
MongoDB Community edition will be enough for testing/developing
purposes. We'll cover about MongoDB Community Edition in this article.
Install MongoDB Community Edition
First, we need to create a package management repository configuration file in our Fedora host. In this article, we'll use mongodb-org-5.0.repo
as repo's file name. Using your favorite text editor, create the file with content below:
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/
8
/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
Note: If you'd like to install another version, adjust accordingly.
After we've created the file, we can run dnf
to install the package.
$ sudo dnf install mongodb-org
Alternatively, to install a specific release of MongoDB, specify each component package individually and append the version number to the package name, as in the following example:
$ sudo dnf install mongodb-org-5.0.5 mongodb-org-database-5.0.5 mongodb-org-server-5.0.5 mongodb-org-shell-5.0.5 mongodb-org-mongos-5.0.5 mongodb-org-tools-5.0.5
Once the installation process finished, we can verify our installation.
Run MongoDB Community Edition
We can start MongoDB service using this command:
$ sudo systemctl start mongod
You can verify that the mongod
process has started successfully by issuing the following command:
$ sudo systemctl status mongod
To make MongoDB start automatically when the system reboot, enter this command:
$ sudo systemctl enable mongod
Once we verify that our mongod
process has started successfully, we can connect to MongoDB server. MongoDB provide an utility (shell) to interact with its database called mongosh
.
To start a mongosh
session on the same host machine as the MongoDB server (mongod
), you can run mongosh
without any command-line options:
$ mongosh
Above command means we want to connect to a MongoDB server (mongod
) that is running on your localhost with default port 27017.
Final Words
Well, that's it. I hope that you now know how to install MongoDB 5.0 on Fedora 35. If you run into any issues or have any feedback feel free to drop a comment below.