Close Menu
JustwebworldJustwebworld
  • Business
  • Food
  • Health
  • Lifestyle
  • Tech
  • Home
  • Travel
  • Culture
  • Money
  • People
  • Sports
  • Auto
  • Digital
  • Mind
  • Fashion
  • Gaming
  • Learn
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn WhatsApp Telegram
Tuesday, May 19
  • About Us
  • Contact Us
  • Advertise With Us
  • Disclaimer
  • Terms & Conditions
  • Privacy Policy
JustwebworldJustwebworld
  • Business
  • Food
  • Health
  • Lifestyle
  • Tech
  • Home
  • Travel
  • Culture
  • Money
  • People
  • Sports
  • Auto
  • Digital
  • Mind
  • Fashion
  • Gaming
  • Learn
JustwebworldJustwebworld
Home » Tech » A Guide to Install MongoDB On Ubuntu

A Guide to Install MongoDB On Ubuntu

Ashley Judd Tech
Facebook Twitter LinkedIn Telegram Pinterest Reddit WhatsApp
Follow Us
WhatsApp Telegram

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

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”,

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.

cards
Powered by paypal
Follow on WhatsApp Follow on Telegram
Share. Facebook Twitter Pinterest LinkedIn Tumblr 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

Samsung ACs in India 2026: Are They Still Worth Buying This Summer?

Snapchat Planets Meaning Explained: Ultimate Snapchat+ Friend Solar System Order, Ranking & Complete Guide 2026

Google’s Account Activity Features that Record Your All Google Products Activity

Unlock the Web! | Best Ways to Access Blocked Websites (Easy & Safe)

Top 15+ Best Hacking Movies Every Computer Lover Must Watch | Cyber Thrillers, Hackers & Tech Films

What Should You Know About Network Security?

Leave A Reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 41.9K other subscribers
Categories
Latest Posts

Best Green Tea Brands In India

Best Microwave Oven Brands In India (Best Microwave Ovens)

Put-in-Bay: Here is What You Should Know About Visiting the Island

Pratibha Ranta Biography: Age, Family, Boyfriend, Net Worth & Untold Story of the Laapataa Ladies Star

Most Popular Chocolate Brands In India for Your Taste Buds

How to Maintain Your Productivity During Your Free Time

Online Masters In Nursing: 5 Things to Know

The Most Powerful Armies In the World

5 Great Ways to Improve Your College Grades

Where to Stay In Santiago de Chile: Best Areas And Neighbourhoods

The content on this website is provided solely for educational and informational purposes. We do not promote, endorse, or deal in any products, services, or activities mentioned. While we strive to share accurate and up-to-date information, we make no warranties regarding completeness, reliability, or accuracy. Any action you take based on the information found here is strictly at your own risk, and we will not be liable for any losses or damages in connection with the use of our website.

DMCA.com Protection Status
Quick Links
Age Calculator
Angel Number Calculator
Case Converter
Sudoku Online
Word Counter
Love Calculator
Jack Doherty YouTuber
Snake Dream Meaning
Get Rid of Cockroaches
Indian Cricket Team Coaches
Best Volleyball Team Names
Useful Links
Number to Words
Period Calculator
Yes-No Picker Wheel
Demon Name Generator
Kingdom Name Generator
Harry Potter Name Generator
Daddy Yankee Biography
Crocodile Dream Meaning
Goa Budget Trip Guide
Maryse Mizanin WWE Diva
Best Cricket Team Names
Helpful Resources
Colors Name In English
Best Computer Brands
WhatsApp Web
Most Beautiful Beaches
Tesla Cybertruck Review
Richest Actors in the World
India Jarvis Actress
Cat Dream Meaning
Belmar Beach New Jersey
Aryna Sabalenka Tennis Superstar
Best WhatsApp Group Names
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
Dude Perfect Net Worth
Horse Dream Meaning
Ramakrishna Beach Visakhapatnam
Anastasia Potapova Tennis Star
Best Funny Team Names
Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn WhatsApp Telegram Threads RSS
  • About Us
  • Contact Us
  • Advertise With Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
  • Web Stories
Copyright © 2012-2026. JustWebWorld - All Rights Reserved. | Sitemap

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

−
×

📚 You May Also Enjoy

Discover a few more helpful articles selected for you 👇
Mobile Covers & Cases
Recommended
Buying an Appropriate Phone Case Based on Your Lifestyle
Tailgating
Recommended
Did You Accidentally Allow A Tailgate? Know the Signs
Facebook Marketing Tips for Small Business
Recommended
20 Proven Facebook Marketing Tips for Small Business
Thanks for reading JustWebWorld ❤️