SurferCloud Blog SurferCloud Blog
  • HOME
  • NEWS
    • Latest Events
    • Product Updates
    • Service announcement
  • TUTORIAL
  • COMPARISONS
  • INDUSTRY INFORMATION
  • Telegram Group
SurferCloud Blog SurferCloud Blog
SurferCloud Blog SurferCloud Blog
  • HOME
  • NEWS
    • Latest Events
    • Product Updates
    • Service announcement
  • TUTORIAL
  • COMPARISONS
  • INDUSTRY INFORMATION
  • Telegram Group
  • banner shape
  • banner shape
  • banner shape
  • banner shape
  • plus icon
  • plus icon

How to Install MongoDB on Ubuntu: Complete Guide

December 13, 2024
3 minutes
TUTORIAL
331 Views

MongoDB is a popular NoSQL database known for its high performance, flexibility, and scalability. This guide walks you through the process of installing MongoDB on Ubuntu step-by-step.

Step 1: Update System Packages

Before installing any software, it’s essential to update your system’s package list. Run the following commands to ensure everything is up to date:

sudo apt-get update
sudo apt-get upgrade -y

This updates package information and upgrades installed packages to their latest versions.

Step 2: Import the MongoDB Public Key

To ensure the authenticity of the software, you need to import the GPG key used to sign the MongoDB packages. Use this command:

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

This imports the official MongoDB key. You should see an "OK" message confirming its success.

Step 3: Add MongoDB Repository

Next, you’ll need to add the MongoDB repository to your system's source list. Create a new repository file using the following command:

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

This step ensures that your system can locate the MongoDB installation packages.

Step 4: Update the Package List

After adding the repository, you’ll need to refresh the package list once more:

sudo apt-get update

This allows Ubuntu to recognize the new MongoDB packages.

Step 5: Install MongoDB

Now you’re ready to install MongoDB. Run the following command:

sudo apt-get install -y mongodb-org

This installs the latest stable version of MongoDB, along with its associated tools.

Step 6: Start and Enable MongoDB

Once the installation is complete, you’ll need to start MongoDB and enable it to launch on system boot. Run the following commands:

sudo systemctl start mongod
sudo systemctl enable mongod
  • start: Starts the MongoDB service.
  • enable: Ensures MongoDB runs automatically after a system reboot.

Step 7: Verify MongoDB Installation

To ensure MongoDB is running correctly, check the status of the service:

sudo systemctl status mongod

If everything is working properly, you’ll see an active (running) status.

Step 8: Test the MongoDB Connection

To test if MongoDB is installed correctly, enter the MongoDB shell by typing:

mongosh

Once inside, you can run simple commands like:

show dbs

This displays a list of databases. If you see output, the installation was successful.

Why Choose SurferCloud?

Looking for a secure and high-performance VPS to run your MongoDB database? SurferCloud provides fast and stable servers with global data centers in Europe, Asia, and the Americas. With robust network infrastructure and affordable pricing, SurferCloud is an ideal choice for hosting your database and applications.

Tags : install MongoDB Ubuntu install MongoDB VPS MongoDB cloud hosting MongoDB server Ubuntu MongoDB Ubuntu setup Ubuntu database server VPS for MongoDB

Related Post

3 minutes TUTORIAL

How to Change the SSH Port on Ubuntu: A Compl

Changing the default SSH port on Ubuntu is an effective...

4 minutes TUTORIAL

Understanding MySQL SHOW PROCESSLIST Command

The MySQL SHOW PROCESSLIST command is an essential tool...

5 minutes INDUSTRY INFORMATION

What is Web Hosting? A Complete Guide to Host

Web hosting is the foundation of any online presence. I...

Affordable CDN

ucdn

2025 Special Offers:

annual vps

Light Server promotion:

ulhost-promo

Cloud Server promotion:

cloud server

Copyright © 2024 SurferCloud All Rights Reserved.  Sitemap.