I am trying to connect to my MongoDB using authentication. I did this on my Mongo server:
use admin db.addUser('adminLogin','adminPassword') db.shutdownServer() exit
Then I started my server again by issuing mongod --auth
I set my db configurations in DataSource.groovy as follows:
grails { mongo { host = "localhost" port = 27017 username = "adminLogin" password = "adminPassword" databaseName = "my DB name" options { autoConnectRetry = true connectTimeout = 300 } } }
When the application starts, the following error message appears:
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
Any suggestion is welcome. Thanks in advance.
authentication database mongodb grails database-connection
Alexandre Bourlier
source share