Home  »  ArticlesGuidesHow ToTechnologyTools   »   Comprehensive Guide: Installing MongoDB on Ubuntu 22.04

Comprehensive Guide: Installing MongoDB on Ubuntu 22.04

MongoDB, a popular NoSQL database, powers many modern applications with its flexibility and scalability. In this tutorial, we’ll explore the step-by-step process of installing MongoDB on Ubuntu 22.04, empowering you to harness the power of this robust database management system.

Step 1: Import MongoDB Repository Key

To begin, import the MongoDB repository key into your Ubuntu 22.04 system to ensure secure package installation:

$ wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

Step 2: Add MongoDB Repository

Next, add the MongoDB repository to your system’s list of package sources:

$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

Step 3: Update Package Index

After adding the repository, update the package index to reflect the changes:

$ sudo apt update

Step 4: Install MongoDB

Now, install MongoDB using the mongodb-org package:

$ sudo apt install mongodb-org

Step 5: Start MongoDB Service

Once MongoDB is installed, start the MongoDB service using the following command:

$ sudo systemctl start mongod

You can also enable MongoDB to start automatically at boot time:

$ sudo systemctl enable mongod

Step 6: Verify MongoDB Installation

To verify that MongoDB has been successfully installed and is running, check the service status:

$ sudo systemctl status mongod

Step 7: Access MongoDB Shell

You can access the MongoDB shell to interact with the database by typing:

$ mongo

Conclusion

Congratulations! You’ve successfully installed MongoDB on Ubuntu 22.04. With MongoDB up and running, you’re now equipped to build powerful and scalable applications that leverage the capabilities of this versatile NoSQL database. Harness the flexibility and scalability of MongoDB to take your projects to new heights.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Articles, Guides, How To, Technology, Tools