sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Install MongoDB 6.0 on Debian 10 & 11
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Install MongoDB 6.0 on Debian 10 & 11

Samuel Siahaan
By Samuel Siahaan
Last updated: June 2, 2023
SHARE

Introduction

In the realm of modern data management, MongoDB has emerged as a leading NoSQL database solution, empowering organizations to handle diverse data types effectively. With the recent release of MongoDB 6.0, there’s a wave of excitement surrounding its enhanced features and capabilities. If you’re an Debian 10 & 11 user, this comprehensive guide will take you through the step-by-step process how to install MongoDB 6.0 on Debian 10/11, enabling you to harness its potential for robust data management and storage.

Contents
IntroductionTable of ContentsEmbracing MongoDB 6.0PrerequisitesInstalling MongoDB 6.0 on Debian 11Step 1: System UpdateStep 2: Install Required PackagesStep 3: Install MongoDB on Debian 10 & 11Step 4: Enable and Start MongoDBStep 5: Secure MongoDB Instance.Create the Admin UserAdd Database and User MongoDBEnabling AuthenticationStep 6: Access MongoDB InstanceStep 7: Change MongoDB default Path (optional)Conclusion

Table of Contents

  • Introduction
  • Embracing MongoDB 6.0
  • Prerequisites
  • Installing MongoDB 6.0 on Debian 11
    • Step 1: System Update
    • Step 2: Install Required Packages
    • Step 3: Install MongoDB on Debian 10 & 11
    • Step 4: Enable and Start MongoDB
    • Step 5: Secure MongoDB Instance.
      • Create the Admin User
      • Add Database and User MongoDB
      • Enabling Authentication
    • Step 6: Access MongoDB Instance
    • Step 7: Change MongoDB default Path (optional)
  • Conclusion

Embracing MongoDB 6.0

MongoDB 6.0 brings with it a range of groundbreaking enhancements that elevate data management to new heights. From native time series collections to advanced full-text search capabilities and bolstered security features, MongoDB 6.0 empowers businesses to navigate through intricate data landscapes with agility, performance, and scalability.

MongoDB uses a flexible data model and supports a wide range of data types, including strings, numbers, booleans, arrays, and embedded documents. This flexibility makes it well-suited for handling unstructured and semi-structured data.

Some key features of MongoDB include:

- Advertisement -
  • Scalability: MongoDB can handle large amounts of data and can be easily scaled horizontally across multiple servers or clusters.
  • High Availability: MongoDB provides replication and automated failover, ensuring that data remains accessible even in the event of hardware or network failures.
  • Flexible Querying: MongoDB supports powerful query capabilities, including rich document querying, indexing, and aggregation framework for complex data retrieval and analysis.
  • Ad hoc Updates: MongoDB allows for flexible updates and modifications to documents without requiring a predefined schema.
  • Integration and Ecosystem: MongoDB has a vast ecosystem with support for multiple programming languages, frameworks, and tools. It also integrates well with other technologies such as Apache Spark, Hadoop, and various cloud platforms.

Prerequisites

Before diving into the installation process, make sure you have the following prerequisites ready:

  • An Debian Server instance with root access or sudo privileges. To set this up, follow our guide : Initial Setup Debian 11 Server: Secure and Efficient
  • Basic familiarity with command-line operations.

Installing MongoDB 6.0 on Debian 11

Proceed by following these comprehensive steps to install MongoDB 6 on your most up-to-date Debian Servers.

Step 1: System Update

To start, ensure that your Debian Server is up to date. go to terminal and run the following command:

samm@mongodb:~$ sudo apt-get update
samm@mongodb:~$ sudo apt-get upgrade -y

Step 2: Install Required Packages

MongoDB provides an official repository for various Linux distributions, including Debian. Add the MongoDB repository to your system with the command:

samm@mongodb:~$ sudo apt install wget curl gnupg gnupg2 software-properties-common apt-transport-https ca-certificates lsb-release

samm@mongodb:~$ curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-6.gpg

#Debian 11
samm@mongodb:~$ echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

#Debian 10
samm@mongodb:~$ echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

Step 3: Install MongoDB on Debian 10 & 11

Now that the repository is configured, proceed to update packages and install MongoDB 6.0.

- Advertisement -
samm@mongodb:~$ sudo apt update
samm@mongodb:~$ sudo apt install mongodb-org

This command will automatically install the MongoDB package along with its required dependencies. Once the install is complete, you’re ready to config, enable and start MongoDB.

Step 4: Enable and Start MongoDB

After the successful installation of MongoDB, enable the MongoDB service to start on system boot and start the service:

samm@mongodb:~$ sudo systemctl enable --now mongod
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /lib/systemd/system/mongod.service

Once the MongoDB is enabled, start the MongoDB

- Advertisement -
samm@mongodb:~$ sudo systemctl start mongod

Confirm that MongoDB is running

samm@mongodb:~$ sudo systemctl status mongod
● mongod.service - intipseleb MongoDB 6.0.5 Document Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-03-20 23:55:47 WIB; 7s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 1200 (mongod)
     Memory: 62.6M
        CPU: 582ms
     CGroup: /system.slice/mongod.service
             └─1200 /usr/bin/mongod --config /etc/mongod.conf

Mar 20 23:55:47 mongodb systemd[1]: Started intipseleb MongoDB 6.0.5 Document Database Server.

To check the version of MongoDB, run following command:

samm@mongodb:~$ mongod --version
db version v6.0.5
Build Info: {
    "version": "6.0.5",
    "gitVersion": "c9a99c120371d4d4c52cbb15dac34a36ce8d3b1d",
    "openSSLVersion": "OpenSSL 1.1.1n  15 Mar 2022",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "debian11",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

Step 5: Secure MongoDB Instance.

After installation, the MongoDB database has no security, One can access it without a password and make undesired changes to your database.Therefore, for enhanced security, consider configuring authentication for MongoDB.

Create the Admin User

samm@mongodb:~$ mongosh 127.0.0.1:27017

Next, generate a user with the name “mongo-admin” – feel free to adjust this name to your liking. Following the integration of the provided script, it becomes essential to set up a password for this particular user.

test> use admin
switched to db admin

admin> db.createUser({ user: "mongo-admin", pwd: "m0ngO4dm1n2023", roles: [{role: "root", db: "admin"}]})
{ ok: 1 }

admin> db.system.users.find()
[
  {
    _id: 'admin.mongo-admin',
    userId: new UUID("af967ad4-9d24-4617-9615-80e793b6b5c1"),
    user: 'mongo-admin',
    db: 'admin',
    credentials: {
      'SCRAM-SHA-1': {
        iterationCount: 10000,
        salt: 'I0esBbduvM8pmHQ2fp2leg==',
        storedKey: 'KQb8b3TSF6py6O75FAwSO3mFZ7w=',
        serverKey: 'kPqwkvgHRsqIjgZ+c2Hl4FhpBis='
      },
      'SCRAM-SHA-256': {
        iterationCount: 15000,
        salt: '8rEzL0MdSZ2WABlcUTDchV3kt2x48epC+IHtKQ==',
        storedKey: 'FrryrJLaIABb7PEebk2zYSfUQa/P9ATkyEWP+TgPZQo=',
        serverKey: 'JLFgZVMZdLUt4zKXdjswysoLkSKlqEAFWc1SvqNJvyQ='
      }
    },
    roles: [ { role: 'root', db: 'admin' } ]
  }
]

Add Database and User MongoDB

To add database and user MongoDB, execute the following commands:

  • Create Database
admin> use sammlinux_db
switched to db sammlinux_db
  • Add User Read Wirite (R/W)
sammlinux_db> db.createUser({ user: "samm-rw", pwd: "s4mm&2023", roles: [{role: "readWrite", db: "sammlinux_db"}]})
  • Add User Read Only (R/O)
sammlinux_db> db.createUser({ user: "samm-ro", pwd: "s4mm#2023", roles: [{role: "read", db: "sammlinux_db"}]})

Enabling Authentication

Afterward, modify the MongoDB configuration file to enable authentication.

samm@mongodb:~$ sudo vi /etc/mongod.conf

net:
  port: 27017
  bindIp: 127.0.0.1,172.32.1.80

security:
  authorization: enabled

samm@mongodb:~$ sudo systemctl restart mongod

Step 6: Access MongoDB Instance

Now, clients are required to authenticate themselves in order to gain access to the database. When accessing MongoDB from a client, utilize the server’s IP address, The syntax employed is as follows:

samm@mongodb:~$ mongosh 127.0.0.1:27017 -u "mongo-admin" -p --authenticationDatabase "admin"
Enter password: m0ngO4dm1n2023

or using the ip address server

samm@mongodb:~$ mongosh 172.32.1.80:27017 -u "mongo-admin" -p --authenticationDatabase "admin"
Enter password: m0ngO4dm1n2023

Current Mongosh Log ID: 63955de17d5b6ddaa159e24e
Connecting to: mongodb://@172.32.1.80:27017/?directConnection=true&authSource=sammlinux_db&appName=mongosh+1.6.2
Using MongoDB: 6.0.5
Using Mongosh: 1.6.2

test> show dbs
sammlinux_db 40.00 KiB
test>

For mongosh info see: mongo documentations.

Step 7: Change MongoDB default Path (optional)

While the default storage path for MongoDB data set to /var/lib/mongo, you can modify this directory as below.

  • Stop the MongoDB service.
samm@mongodb:~$ sudo systemctl stop mongod
  • Create a new directory for MongoDB data.
samm@mongodb:~$ sudo mkdir -p /database/mongodb
samm@mongodb:~$ sudo mkdir -p /database/mongodb/data
samm@mongodb:~$ sudo mkdir -p /database/mongodb/log
samm@mongodb:~$ sudo chown mongodb.mongodb -R /database/mongodb
  • Copy contents to the new directory.
samm@mongodb:~$ sudo rsync -av /var/lib/mongodb /database/mongodb/data
  • Rename the old directory for backup.
samm@mongodb:~$ sudo mv /var/lib/mongodb /var/lib/mongodb.bak

After implementing these adjustments, proceed to restart the MongoDB service. MongoDB will commence utilizing the newly designated directory to store its data.

samm@mongodb:~$ sudo systemctl restart mongod

Conclusion

Congratulations! You’ve successfully install MongoDB 6.0 on your Debian 10/11 instance. This sophisticated NoSQL database empowers you to manage and manipulate data with flexibility and efficiency. As you embark on your journey with MongoDB 6.0, remember to explore its enhanced features and capabilities, leveraging its potential to streamline your data management strategies. Stay attuned to MongoDB’s documentation and updates to ensure you’re making the most of this powerful tool in the realm of modern data management.

Also Read Our Other Guides :

  • How To Install MongoDB 6.0 on Ubuntu Server 22.04
  • How To Install MongoDB 6.0 on Rocky Linux 9
  • How To Install DBeaver Community on Ubuntu 22.04

Finally, now you have learned how to install MongoDB 6.0 on Debian 10/11.

TAGGED:DatabasesDebianMongoDBNoSQL

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Install and Use Docker Compose on Centos 7
Next Article How To Install Redis on Debian 11 Server
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install Redis on Debian 11 Server
Debian

You Might Also Like

Rocky Linux

How To Install MongoDB 6.0 on Rocky Linux 9

18 Min Read
Ubuntu

How To Install DBeaver Community on Ubuntu 22.04

7 Min Read
Debian

How To Install MySQL 8.0 on Debian 11

14 Min Read
Debian

How To Set Up a Firewall with UFW on Debian 11

8 Min Read
Debian

Initial Setup Debian 11 Server: Secure and Efficient

17 Min Read
Ubuntu

How To Install MongoDB 6.0 on Ubuntu Server 22.04

10 Min Read
Debian

How To Install and Setup Node.js on Debian 11

6 Min Read
Debian

How To Install Apache Solr 9.1 on Debian 11

9 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?