authenticationDatabase here is the database name where the user was created. Mongo -u -p -authenticationDatabase admin To connect to the mongo shell with authentication: With a custom config file: This is when the latter configs has to be present in the custom config file.Start mongod like: usr/bin/mongod -config.Without a custom config file: This is when the former auth flag is applicable.Once credentials are obtained, there are two ways to enable authentication: First of all, authentication credentials (ie user/password) in both cases has to be created by executing db.createUser query on the default admin database. Some of the answers are sending mixed signals between using -auth command line flag or setting config file property. Last but not least due to users not reading the commands I posted correctly regarding the -auth flag, you can set this value in the configuration file for mongoDB if you do not wish to set it as a flag. Roles: [ ,Įxit the mongo shell, re-connect, authenticate as the user. Start MongoDB without access control ( /data/db or where your db is). Wow so many complicated/confusing answers here. The username & password will work the same way for mongodump and mongoexport. mongodb/bin/mongo localhost:27017/admin -u admin -p 123456 Ii) run & login to mongo in command line. mongodb/bin/mongod -auth -dbpath /mnt/db/ UPDATE Here is the solution I ended up using 1) At the mongo command line, set the administrator: Roles also have a set of document- and field-level permissions that a user has when assigned the role. A role has an 'apply when' expression that determines whether App Services should assign the role to a user. A user with dbadmin or useradmin can admin the database. Even if I connect to the database remotely, I am not prompted for user name & password. A role is a named set of permissions that a user may have for documents in a MongoDB collection. Grant read and write without dropCollection in MongoDB Atlas. Its a bit confusing - I believe you will need to grant yourself readWrite to query a database. I tried the tutorial from the MongoDB site and did following: use adminĪfter that, I exited and ran mongo again. I want to set up user name & password authentication for my MongoDB instance, so that any remote access will ask for the user name & password.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |