Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.42 KB

README.md

File metadata and controls

38 lines (29 loc) · 1.42 KB

Setting up mongodb for authentication

  • Check the docs at: http://docs.mongodb.org/manual/tutorial/control-access-to-mongodb-with-authentication/
  • Short version here:
    1. Start mongod (without -auth)

    2. Start mongo from the cmd-line as

         mongo admin
      
    3. Then create the admin user with

         db.addUser("<admin-username>", "<admin-password>")
      
    4. The switch the database to swk, which is the database for the app

         use swk
         db.addUser("<app-username>", "<app-password>")
         exit
      
    5. Shutdown mongod from the mongo console

         use admin
         db.shutdownServer()
      
    6. Start mongod -auth

    7. Edit start.sh, replace the values of MONGO_USER and MONGO_PASS with <app-username> and <app-password>

Remember that once authentication is enabled, the db can only be shutdown via:

		use admin
		db.auth("<admin-username>", "<admin-password>")
		db.shutdownServer()

Some hints on database handling with mongo:

  • Several statements for easy useage in the mongo command line client
    • show dbs - show all availabe databases
    • use swk - use swk database
    • show collections - show all available collections
    • db.memberstore.find() - show all entries in the collection 'memberstore'
    • db.dropDatabase() - drop currently connected database