Last active
June 20, 2018 12:43
-
-
Save razorcd/0a320188b1764053200744ef34e3a78c to your computer and use it in GitHub Desktop.
create user in mongo db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//login as admin using the db where the admin user is defined | |
mongo --port 27017 -u "admin" -p "admin" --authenticationDatabase "admin" | |
// or the default: | |
mongo --port 27017 -u "root" -p "password" --authenticationDatabase "root" | |
//list all system users: | |
db.system.users.find() | |
//to add a new user for a specific DB: | |
use cm-db | |
db.createUser({user: "cm-user",pwd: "cm-pass",roles: [{"role" : "dbOwner","db" : "cm-db"}]}) | |
db.getUsers() // should show user | |
use admin | |
db.system.users.find() // new user should show here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment