Close Menu
JustwebworldJustwebworld
  • Astrology
  • Business & Finance
    • Cryptocurrency
    • Make Money
    • Entrepreneur
    • Brands
    • Companies
    • Personal Finance
      • Banking
      • Insurance
      • Trading and Investing
  • Tech
    • Computing
    • Cybersecurity
    • Electronics
    • Android
    • Apple
    • Gadgets
    • Social Media
    • Mobile Apps
    • Softwares
  • Education
    • Vocabulary
    • Abbreviations
    • General Knowledge
    • Writing & Translation
  • Lifestyle
    • Beauty & Cosmetics
    • Fashion & Style
    • Furniture & Decor
    • Luxury
    • People & Relationships
    • Pets and Animals
    • Shopping
    • Parenting
    • Gardening
    • Birthdays
  • Health
  • Travel
  • Auto
  • Gaming
  • Food
  • Entertainment
  • Sports
Facebook X (Twitter) Instagram
Saturday, May 24
  • About
  • Contact Us
  • Advertise With Us
  • Disclaimer
  • Terms & Conditions
  • Privacy Policy
JustwebworldJustwebworld
  • Astrology
  • Business & Finance
    • Cryptocurrency
    • Make Money
    • Entrepreneur
    • Brands
    • Companies
    • Personal Finance
      • Banking
      • Insurance
      • Trading and Investing
  • Tech
    • Computing
    • Cybersecurity
    • Electronics
    • Android
    • Apple
    • Gadgets
    • Social Media
    • Mobile Apps
    • Softwares
  • Education
    • Vocabulary
    • Abbreviations
    • General Knowledge
    • Writing & Translation
  • Lifestyle
    • Beauty & Cosmetics
    • Fashion & Style
    • Furniture & Decor
    • Luxury
    • People & Relationships
    • Pets and Animals
    • Shopping
    • Parenting
    • Gardening
    • Birthdays
  • Health
  • Travel
  • Auto
  • Gaming
  • Food
  • Entertainment
  • Sports
JustwebworldJustwebworld
Home»Technology»A Guide to Install MongoDB On Ubuntu

A Guide to Install MongoDB On Ubuntu

Ashley JuddBy Ashley Judd Technology
Facebook Twitter LinkedIn Telegram Pinterest Reddit Email WhatsApp
Follow Us
WhatsApp Telegram
Share
Facebook Twitter LinkedIn Pinterest Reddit Telegram WhatsApp

Prerequisites.

  • Ubuntu 20.04 server.
  • A sudo user.

Table of Contents

Toggle
  • Introduction to MongoDB
  • Introduction to Ubuntu
  • Install MongoDB on Ubuntu Steps
    • Install MongoDB on Ubuntu Steps: Install MongoDB Server
    • Install MongoDB on Ubuntu Steps: Run MongoDB
    • Install MongoDB on Ubuntu Steps: Configuration
    • Install MongoDB on Ubuntu Steps: Uninstalling MongoDB
  • Conclusion

Introduction to MongoDB

MongoDB is a cross-platform database that uses documents that are JSON-like with schemas that can be customized.

Install MongoDB On Ubuntu

This NoSQL database application focuses on documents and supports search, transactional, mobile, and analytical use cases. MongoDB can deliver these features while employing a robust data model and a developer-friendly query interface.

You can simply preserve data integrity and provide high availability with MongoDB to help your organization flourish. Before moving further, MongoDB verifies that your mission-critical workloads fulfill compliance and security criteria.

With indexing, sharding, pre-built replication, performance tools, and more, MongoDB gives you the confidence to run in production.

Introduction to Ubuntu

Ubuntu is an open-sourced operating system that is based on Linux. It supports computers, cellphones, and network servers. The system was created by Canonical Ltd which is based in the UK.

Install MongoDB on Ubuntu Steps

Here are the key steps that you may implement to install MongoDB on Ubuntu, configure and run it:

Install MongoDB on Ubuntu Steps: Install MongoDB Server

  • Step 1: To import the MongoDB public GPG Key, type the following command in a terminal window.

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

This should respond with an “OK”.

  • Step 2: Create a list file for your MongoDB package under the /etc/apt/sources.list.d directory.

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: Refresh the local package database.

sudo apt-get update

Also Read: Your Complete Guide to Understanding Aircall’s VoIP Phone System Your Complete Guide to Understanding Aircall’s VoIP Phone System

In the following location, the installation script creates a data directory.

/var/lib/mongodb

MongoDB reports activity logs to a mongod.log file which can be located from this location:

/var/log/mongodb

  • Step 4: Install the MongoDB Packages

sudo apt-get install -y mongodb-org

Despite the fact that you can select any version of MongoDB, apt-get will automatically upgrade the packages whenever a newer version becomes available. You can pin the package to the currently installed version to prevent unwanted upgrades:

echo “mongodb-org hold” | sudodpkg –set-selections

echo “mongodb-org-database hold” | sudodpkg –set-selections

echo “mongodb-org-server hold” | sudodpkg –set-selections

echo “mongodb-org-shell hold” | sudodpkg –set-selections

echo “mongodb-org-mongos hold” | sudodpkg –set-selections

echo “mongodb-org-tools hold” | sudodpkg –set-selections

Install MongoDB on Ubuntu Steps: Run MongoDB

The mongod service manages the MongoDB package. To manage it, use the systemctl commands.

  • Step 1: Check the status.

$ sudosystemctl status mongod

  • Step 2: Start MongoDB.

sudosystemctl start mongod

  • Step 3: Allow MongoDB to be started on boot.

$ sudosystemctl enable mongod

  • Step 4: Verify whether MongoDB has started.

sudosystemctl status mongod

  • Step 5: Stop MongoDB

sudosystemctl stop mongod

  • Step 6: Restart MongoDB

sudosystemctl restart mongod

  • Step 7: Start using MongoDB by starting a mongosh session.

mongosh

Install MongoDB on Ubuntu Steps: Configuration

Because you haven’t configured MongoDB authentication, you’ll get some starting warnings when the service loads.

Current Mongosh Log ID: 612e0b0da174636a8c40e2de

…

Using MongoDB: 5.0.2

Using Mongosh: 1.0.5

…

test >

Step 1: Switch to admin

test > use admin

Step 2: Run the following command to create an administrator user.

admin>db.createUser(

{

user: “mongo_db_admin”,

Also Read: Help With Choosing the POS System for Your Business Help With Choosing the POS System for Your Business

pwd: passwordPrompt(),

roles: [ { role: “userAdminAnyDatabase”, db: “admin” }, “root”]

}

)

Enter your password and continue.

Step 3: Exit the command line interface

admin> quit

Step 4: To enable authorization, open the MongoDB file using a nano text editor

$ sudo nano /etc/mongod.conf

Step 5: Locate the security directive that is commented out and change the value.

security:

authorization: enabled.

Save and close the file.

Step 6: Restart the server.

$  sudosystemctl restart mongod

Install MongoDB on Ubuntu Steps: Uninstalling MongoDB

You must delete the MongoDB applications, the configuration files, and any directories containing data and logs to entirely remove MongoDB from a system.

This process is not reversible and it completely removes MongoDB, its configuration, and all of the databases in it, so make sure you backup your data beforehand.

Step 1: Stop MongoDB

sudo service mongod stop

Step 2: Remove all the packages you had installed.

sudo apt-get purge mongodb-org*

Step 3: Delete all the databases and the log files which were created.

sudo rm -r /var/log/mongodb

sudo rm -r /var/lib/mongodb

Conclusion

This blog discusses the steps to install MongoDB on Ubuntu and configure it. This includes a brief about MongoDB and how to run it. It also discusses the steps to uninstall MongoDB from your system.

Follow on WhatsApp Follow on Telegram
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Telegram WhatsApp Copy Link
Previous ArticleWhat Experience And Skills Do You Need To Work In Medical Translations?
Next Article What Forex Traders Should Know About ECN And How to Use It
Ashley Judd

Ashley Judd is a powerhouse of creativity, turning words into magic across every topic you can think of! Whether it’s tech, lifestyle, health, business, or beyond, she knows how to hook readers with engaging, easy-to-read, and insightful content. Her writing isn’t just informative-it’s entertaining, relatable, and packed with value. With a passion for storytelling and a love for exploring new ideas, Ashley makes every piece she writes a must-read. When she’s not crafting compelling content, you’ll find her buried in books, sipping coffee, or dreaming up her next big writing adventure!

Related Posts

AI Tools for Building MVPs: How Founders Skip the Dev Backlog in 2025

China Telecom and ZTE Launched AI-Powered Generative Intelligent Network at Barcelona’s MWC25

The Most Effective Ways To Get Cash For Your Laptop In The City Today

Airtel Broadband: The Best Unlimited Data Plans for Your Home Internet

DeepSeek: The Future of Intelligent Search | AI-Driven Answers in Seconds

How to Choose the Best Proxy Provider for Your Needs

Leave A Reply

Categories
Archives

Seeing 808 Everywhere? Angel Number 808 Meaning, Love, Career & Destiny Explained

FC Goa: Indian Super League Powerhouse | Players, Records & Titles

Tesla Model Y 2025 Review: Price, Range, Specs & Features | America’s Top Electric SUV

Sasha Montenegro: Mexican Cinema Icon | Biography, Movies, Husband, Life & Legacy

The Price of Keeping Financial Secrets in a Marriage

Latest Anime Saga Codes (May 2025) – Redeem Free Rewards | Before They Expire!

Jose Alvarado NBA 2025: Inspiring Journey, Impressive Stats, Big Contract & Puerto Rico Pride

Who is Hazel Brugger? Top Swiss Comedian, Eurovision Host & Comedy Queen of Europe

Luke Kornet Full Player Profile | Age, Height, Net Worth, Career Stats 2025

Who Is Brent Faiyaz? Age, Songs, Albums, Net Worth & Tour 2025

DMCA.com Protection Status
Quick Links
Age Calculator
Angel Number Calculator
Case Converter
Sudoku Online
Word Counter
Love Calculator
Useful Links
Number to Words
Period Calculator
Yes-No Picker Wheel
Demon Name Generator
Kingdom Name Generator
Harry Potter Name Generator
Helpful Resources
Colors Name In English
Best Computer Brands
WhatsApp Web
Most Beautiful Beaches
Tesla Cybertruck Review
Richest Actors in the World
Explore More
Good Morning Handsome
Best English Songs of All Time
Cricket World Cup Winners
Ways to Say Rest In Peace
Britain’s Got Talent Winners
American Idol Winners
Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn WhatsApp Telegram Threads RSS
  • About
  • Contact Us
  • Advertise With Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
  • Web Stories
Copyright © 2012-2025. JustWebWorld - All Rights Reserved. | Sitemap

Type above and press Enter to search. Press Esc to cancel.

×

👇 Bonus Reads for You 🎁

Kenya Preferring Mobile Money
Why Is Kenya Preferring Mobile Money Over Cash?
App Technology
App Technology: What’s Changing In the Finance Sector?
Vulnerability Assessment and Penetration Testing
Looking for VAPT In India? Here’s What You Need
Power of Strong Neodymium Magnets
Unleashing the Power of Strong Neodymium Magnets: Exploring Their Limitless Potential