Win a copy of The Career Toolkit this week in the Jobs Discussion forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Frits Walraven
  • Piet Souris

Enabling user authentication in MongoDB

Posts: 2407
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you're just starting out with MongoDB e.g. playing with it on your home PC, you don't need to worry about setting up database users etc, because authentication is disabled by default.

But once you start thinking about building an application with MongoDB, you'll probably need to think about which users should be able to read/write to which databases/collections. For example, ordinary users should probably only be able to read/write certain collections in a given database, while your application admin would need to be able to do things like create collections and create indexes etc in the application database.

Coming from an RDBMS background, I found MongoDB's user set-up a bit confusing, so I put together a blog post on how to set up a couple of users for an application database, where some users can only read/write in a specific database/collection.

It's just a learning example, so don't rely on this for your production systems - always rely on the MongoDB documentation for real-world applications! But it might help you to get started with MongoDB's approach to user permissions etc.
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To enable user authentication in MongoDB start MongoDB with --auth option
MongoDB requires all users to authenticate themselves. There are many authentication mechanism:
  • db.auth() method provide authentication
  • Kerberos Authentication mechanism system
      Bookmark Topic Watch Topic
    • New Topic