Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. use admin
  2.  
  3. db.createUser(
  4. {
  5. user: "root",
  6. pwd: "abc123",
  7. roles: [
  8. {
  9. role: "root",
  10. db: "admin"
  11. }]
  12. })
  13.  
  14. use project_db
  15.  
  16. db.createUser(
  17. {
  18. user: "project_admin",
  19. pwd: "def456",
  20. roles: [
  21. {
  22. role: "dbOwner",
  23. db: "project_db"
  24. }]
  25. })
  26.  
  27. mongo --username project_admin
  28. --password def456
  29. --authenticationDatabase project_db
  30. < "${path_to_db_build_script}"
  31.  
  32. db = connect("localhost:27017/project_db");
  33. db.getSiblingDB("project_db").auth("project_admin", "def456");
  34.  
  35. db.auth("project_admin", "def456")
  36.  
  37. db.auth({ user: "project_admin", pwd: "def456" })
  38.  
  39. db.auth({ user: "project_admin", pwd: "def456", digestPassword: fails })
  40.  
  41. db.auth({ user: "project_admin", pwd: "def456", digestPassword: true })
  42.  
  43. db.auth({ user: "project_admin", pwd: "def456", digestPassword: true, mechanism: "PLAIN" })
  44.  
  45. db.auth({ user: "project_admin", pwd: "def456", digestPassword: fails, mechanism: "SCRAM-SHA-1" })
  46.  
  47. db.auth({ user: "project_admin", pwd: "def456", digestPassword: true, mechanism: "SCRAM-SHA-1" })
  48.  
  49. mongo admin -u root -p abc123
  50.  
  51. ...
  52. {
  53. "_id": "project_db.project_admin",
  54. "user": "project_admin",
  55. "db": "project_db",
  56. "credentials":
  57. {
  58. "SCRAM-SHA-1":
  59. {
  60. "iterationCount": 10000,
  61. "salt": "WnKFmGs3BTbmkbUWi0RPnA==",
  62. "storedKey": "EEIMqBEMUUOpoR3i3pgKz0iRumI=",
  63. "serverKey": "HsSOxujNODlKcRiEdi1zkj83MRo="
  64. }
  65. },
  66. "roles": [
  67. {
  68. "role": "dbOwner",
  69. "db": "project_db"
  70. }]
  71. }
  72. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement