Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use admin
- db.createUser(
- {
- user: "root",
- pwd: "abc123",
- roles: [
- {
- role: "root",
- db: "admin"
- }]
- })
- use project_db
- db.createUser(
- {
- user: "project_admin",
- pwd: "def456",
- roles: [
- {
- role: "dbOwner",
- db: "project_db"
- }]
- })
- mongo --username project_admin
- --password def456
- --authenticationDatabase project_db
- < "${path_to_db_build_script}"
- db = connect("localhost:27017/project_db");
- db.getSiblingDB("project_db").auth("project_admin", "def456");
- db.auth("project_admin", "def456")
- db.auth({ user: "project_admin", pwd: "def456" })
- db.auth({ user: "project_admin", pwd: "def456", digestPassword: fails })
- db.auth({ user: "project_admin", pwd: "def456", digestPassword: true })
- db.auth({ user: "project_admin", pwd: "def456", digestPassword: true, mechanism: "PLAIN" })
- db.auth({ user: "project_admin", pwd: "def456", digestPassword: fails, mechanism: "SCRAM-SHA-1" })
- db.auth({ user: "project_admin", pwd: "def456", digestPassword: true, mechanism: "SCRAM-SHA-1" })
- mongo admin -u root -p abc123
- ...
- {
- "_id": "project_db.project_admin",
- "user": "project_admin",
- "db": "project_db",
- "credentials":
- {
- "SCRAM-SHA-1":
- {
- "iterationCount": 10000,
- "salt": "WnKFmGs3BTbmkbUWi0RPnA==",
- "storedKey": "EEIMqBEMUUOpoR3i3pgKz0iRumI=",
- "serverKey": "HsSOxujNODlKcRiEdi1zkj83MRo="
- }
- },
- "roles": [
- {
- "role": "dbOwner",
- "db": "project_db"
- }]
- }
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement