• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How To Install MongoDB on Debian 11.3

  • 00:32 cat /etc/os-release
  • 00:42 install gnupg2 wget
  • 01:01 wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
  • 01:15 echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
  • 01:30 apt update
  • 01:40 apt install mongodb-org
  • 02:06 mongod --version
  • 02:24 systemctl start mongod
  • 02:37 systemctl enable mongod
  • 02:50 mongosh
  • 03:05 use admin
  • 03:40 db.createUser(
  • 05:40 show users
  • 06:05 nano /etc/mongod.conf
  • 07:04 systemctl restart mongod
  • 07:28 mongosh -u Vultr -p topSecret1
{{postValue.id}}

To Install MongoDb on Debian 11.3

Introduction:

MongoDB is a NoSQL database application used to store data as JSON-like documents on servers. MongoDB has modern infrastructure with various services while being malleable and friendly to use, providing freedom to developers and their code.

Installation Procedure:

Step 1: Check the OS version by using the below command

[root@linuxhelp ~]# cat /etc/os-release

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye

Step 2: Add MongoDB APT repository on Debian 11 by using the below command

[root@linuxhelp ~]#  install gnupg2 wget

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
wget is already the newest version (1.21-1+deb11u1).

Step 3: Add MongoDB APT repository by using the below command

[root@linuxhelp ~]#  wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
[root@linuxhelp ~]#  echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main

Step 4: Update the packages by using the below command

[root@linuxhelp ~]#  apt update

Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Hit:2 http://deb.debian.org/debian bullseye InRelease                                           
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
108 packages can be upgraded. Run 'apt list --upgradable' to see them.

Step 5: Install MongoDB 5.0 the packages by using the below command

[root@linuxhelp ~]# apt install mongodb-org

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Unpacking mongodb-database-tools (100.5.2) ...
Selecting previously unselected package mongodb-mongosh.
Preparing to unpack .../2-mongodb-mongosh_1.5.0_amd64.deb ...
Adding user mongodb to group mongodb
Done.

Step 6: Check the Mangod version by using the below command

[root@linuxhelp ~]#  mongod --version

db version v5.0.9
Build Info: {
    "version": "5.0.9",
    "gitVersion": "6f7dae919422dcd7f4892c10ff20cdc721ad00e6",
    "openSSLVersion": "OpenSSL 1.1.1n  15 Mar 2022",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "debian10",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

Step 7: Configure MongoDB by using the below command

[root@linuxhelp ~]# systemctl start mongod

[root@linuxhelp ~]# systemctl enable mongod

Step 8: Secure MongoDB 5.0 Instance by using the below command

[root@linuxhelp ~]#  mongosh
Current Mongosh Log ID: 62a0f9e18cbb755cef3b077f
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.0
Using MongoDB:          5.0.9
Using Mongosh:          1.5.0
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
   The server generated these startup warnings when booting

Step 9: Switch the Admin Database by using the below command

admin> use admin
already on db admin

Step 10: Create user in mongo Database by using the below command

admin> db.createUser(
...     {
.....         user: "Vultr",
.....         pwd:  "topSecret1",
.....         roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
.....     }
... )
{ ok: 1 }

Step 11: Show user in mongo Database by using the below command

admin> show users
[
  {
    _id: 'admin.Vultr',
    userId: UUID("ad8afccc-d6b0-4326-ae02-a426c9654e08"),
    user: 'Vultr',
    db: 'admin',
    roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ],
    mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
  }
]
admin>
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
admin>

Step 12: Edit the MongoDB configuration file and enable authentication.

[root@linuxhelp ~]#  nano /etc/mongod.conf
Security: Authorization: enable

Step 13. Restart the mongo dB by using the below command

[root@linuxhelp ~]#  systemctl restart mongod

Step 14: Open the MongoDB Database authentication

 [root@linuxhelp ~]#  mongosh -u Vultr -p topSecret1

Current Mongosh Log ID: 62a0fb2bc00cb9c54d18e76f
Connecting to:          mongodb://<credentials>@127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.0
Using MongoDB:          5.0.9
Using Mongosh:          1.5.0

Conclusion

We have reached the end of this article. In this guide, we have walked you through the steps required to install MongoDB on Debian 11.3. Your feedback is much welcome.

Tags:
michael
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

1. How to Install MongoDB?

A

apt install mongodb-org

Q

2. How to Create a user in Mongo Database?

A

admin> db.createUser(
... {
..... user: "Vultr",
..... pwd: "topSecret1",
..... roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
..... }
... )

Q

3. What is MongoDB APT repository?

A

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

Q

4. How to restart MongoDB?

A

systemctl restart Mongodb

Q

5. How to open the MongoDB Database authentication.

A

mongosh -u [username] -p [passwd]

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaac ?
How to run windows application in linux

I need to run the windows application in my Linux machine, instead of installing from yum repo or any other repos. How to do that..??

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.