Dev Space
DemoGitHubDiscord Server
  • 🏠Dev Space
  • 💡Features
  • 📄Changelogs
  • â„šī¸Credits
  • Guides
    • 🌐Website Guides
      • Install Dev Space Website
    • ⚡Agent Guides
      • Install Dev Space Agent
  • MongoDB Guides
    • MongoDB Admin
  • What is docker?
  • Accounts
    • 🙂Profile
  • Teams
    • đŸ˜ī¸Teams
    • 🔒Permissions
    • 🤖API
      • Client
      • Console
      • Docker
      • Roles
      • Members
      • Servers
      • Users
      • Models
  • Team Resources
    • đŸ–Ĩī¸Servers
    • 🎮Consoles
Powered by GitBook
On this page
  1. MongoDB Guides

MongoDB Admin

Set/reset admin password
  1. Make sure authentication is disabled in /etc/mongod.conf by setting security authorization: disabled or comment it out.

  2. Restart MongoDB using sudo service mongod restart

  3. Access the mongo shell commands using the terminal command mongosh this will start an interactive shell session.

  4. Type db.getSiblingDB("admin").changeUserPassword("root", "PASSWORD") and change PASSWORD to your choice, please use a random password with special characters.

  5. Type exit to exit the mongo shell.

  6. Enable authentication in /etc/mongod.conf by setting security authorization: enabled

  7. Restart MongoDB again sudo service mongod restart

Mongo shell authentication

If authentication is enabled you need to login to mongodb in the terminal using this.

mongosh -u root -p PASSWORD

Replace PASSWORD with the root mongo password.

Add user to database
  1. Change USER to username and both DATABASE to your database name.

  2. db.getSiblingDB("admin").grantRolesToUser( "USER", [ { role: "dbAdmin", db: "DATABASE" }, { role: "readWrite", db: "DATABASE" } ] )

PreviousMongoDB GuidesNextWhat is docker?

Last updated 3 months ago