Exception authenticating MongoCredential and Uncategorized Mongo Db Exception Exception authenticating MongoCredential and Uncategorized Mongo Db Exception mongodb mongodb

Exception authenticating MongoCredential and Uncategorized Mongo Db Exception


As per #46934427, setting spring.data.mongodb.authentication-database=admin would probably fix your issue.

The default database in MongoDB is test, therefore, it's likely you are attempting to authenticate against the test database. Switching to the admin database (the common place for users to be created), might fix your issue.


You could try this:

spring.data.mongodb.uri=mongodb://user:passwod@localhost/test?authSource=admin


Add user admin into your database. Open installed folder and open the mongo.exe file and run below command : use admindb.createUser({user: "admin",pwd: "admin",roles: [ { role: "userAdminAnyDatabase", db: "admin" },{ role: "dbAdminAnyDatabase", db: "admin" },{ role: "readWriteAnyDatabase", db: "admin" } ]})