Advertisement
Guest User

Untitled

a guest
May 28th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # Create your superuser
  2. $ mongo
  3. > use admin
  4. > db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
  5. > exit
  6.  
  7. # Alias for convenience (optional and at your own risk)
  8. $ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
  9. $ source ~/.bash_profile
  10.  
  11. # Add user to your DB
  12. $ mongo
  13. > use some_db
  14. > db.createUser(
  15. {
  16. user: "mongouser",
  17. pwd: "someothersecret",
  18. roles: ["readWrite"]
  19. }
  20. )
  21.  
  22. # If you get locked out, start over
  23. sudo service mongod stop
  24. sudo mv /data/admin.* . # for backup
  25. sudo service mongod start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement