Advertisement
evilqubit

add user to mongo db

Mar 25th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Start the shell and add an administrative user for the server.
  2.  
  3. $ ./mongo
  4. use admin
  5. db.addUser("mongoadmin", "anadminpassword")
  6.  
  7. Note: On my system, typing ./mongo doesn’t work, but plain mongo does.
  8. Authenticate, still in the shell.
  9.  
  10. 1
  11. db.auth("mongoadmin", "anadminpassword")
  12. Configure a specific user for another database.
  13.  
  14. 1
  15. 2
  16. use projectx
  17. db.addUser("joe", "passwordForJoe")
  18. Exit the MongoDB shell.
  19.  
  20. 1
  21. exit
  22. Edit the mongodb.conf file to enable authentication.
  23.  
  24. 1
  25. sudo nano /etc/mongodb.conf
  26.  
  27. Uncomment this line.
  28.  
  29. 1
  30. auth=true
  31. Restart MongoDB
  32.  
  33. 1
  34. sudo /etc/init.d/mongodb restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement