title: Grails - Connect to a MongoDB database using authentication
body: <p>I am trying to connect to my MongoDB using authentication. 
  I did this on my Mongo server: </p>
  
  <pre><code>use admin
  db.addUser('adminLogin','adminPassword')
  db.shutdownServer()
  exit
  </code></pre>
  
  <p>Then I started my server again issuing <code>mongod --auth</code></p>
  
  <p>I set my db configurations in DataSource.groovy as follows:</p>
  
  <pre><code>grails {
      mongo {
          host = "localhost"
          port = 27017
          username = "adminLogin"
          password = "adminPassword"
          databaseName = "my DB name"
          options {
              autoConnectRetry = true
              connectTimeout = 300
          }
      }
  }
  </code></pre>
  
  <p>I get the following error message when I start my application:</p>
  
  <pre><code>ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean
   with name 'mongoDatastore': FactoryBean threw exception on object creation; nested 
  exception is org.springframework.data.mongodb.CannotGetMongoDbConnectionException:
   Failed to authenticate to database
  </code></pre>
  
  <p>Any suggestion is most welcome. 
  Thanks in advance. </p>