Lennart Koopmann

{ :blog => true }

MongoMapper/Rails: Connect to a MongoDB database with username and password

MongoMapper is a great project but missing a lot of documentation in some core parts. I wanted to find out how to connect to a MongoDB instance that requires authentication and this is how I did it:

First step: Adding a new section to your database configuration

# config/database.yml
mongodb:
  hostname: localhost
  database: graylog2
  port: 27017
  authenticate: true
  username: graylog2user
  password: graylog2pw

Read More