Created
January 10, 2018 16:57
-
-
Save afonsoaugusto/64da35d1f05ee3e17f43ca40453c7a55 to your computer and use it in GitHub Desktop.
This file contains 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
use admin | |
db.createUser( | |
{ | |
user: "alice", | |
pwd: "secret", | |
roles: [ { role: "root", db: "admin" } ] | |
} | |
) | |
sudo mongod --auth --port 27017 --dbpath=/var/lib/mongodb | |
sudo mongod --auth --port 27017 --dbpath=/var/lib/mongodb --config=/etc/mongod.conf | |
mongod --auth --port 27017 --dbpath /data/db1 | |
mongo --port 27017 -u "alice" -p "secret" --authenticationDatabase "admin" | |
> db.runCommand({getParameter: 1, authenticationMechanisms: 1}) | |
{ | |
"ok" : 0, | |
"errmsg" : "getParameter may only be run against the admin database.", | |
"code" : 13, | |
"codeName" : "Unauthorized" | |
} | |
> use admin | |
switched to db admin | |
> db.runCommand({getParameter: 1, authenticationMechanisms: 1}) | |
{ | |
"authenticationMechanisms" : [ | |
"MONGODB-CR", | |
"MONGODB-X509", | |
"SCRAM-SHA-1" | |
], | |
"ok" : 1 | |
} | |
mongo -u alice -p secret --eval "db.runCommand({getParameter: 1, authenticationMechanisms: 1})" --authenticationDatabase admin | |
db.runCommand({getParameter: 1, authenticationMechanisms: 1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment