Summary
A MongoDB source cannot be created in Dremio if the specified authentication database does not exist or is not associated with the user you are trying to connect with.
Reported Issue
When configuring a MongoDB source with "Master Credentials" authentication, the source settings fail to save, and an error is reported at the top of the configuration window: "Could not find/access authentication database <auth db name>".
Relevant Versions
All versions of Dremio.
Troubleshooting Steps
Check the Dremio coordinator server log for errors similar to the following:
2025-01-15 05:15:43,376 [source-management43] ERROR c.d.p.mongo.MongoDocumentHelper - Failed to run command `Document{{ping=1}}`, exception : com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='dremio_mongo_user', source='admin', password=<hidden>, mechanismProperties=<hidden>}
2025-01-15 05:15:43,377 [source-management43] ERROR c.d.p.mongo.MongoDocumentHelper - Mongo command returned with invalid return code (not OK), Could not authenticate user `dremio_mongo_user` for database `admin` : {"Exception": "com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='dremio_mongo_user', source='admin', password=<hidden>, mechanismProperties=<hidden>}"}
2025-01-15 05:15:43,377 [source-management43] INFO c.d.p.m.connection.MongoConnection - User Error Occurred [ErrorId: b934aa02-81c4-4b82-9c93-e13c9f64e5fe]
com.dremio.common.exceptions.UserException: Could not find/access authentication database admin.
at com.dremio.common.exceptions.UserException$Builder.build(UserException.java:984)
at com.dremio.plugins.mongo.connection.MongoConnection.authenticate(MongoConnection.java:78)
at com.dremio.plugins.mongo.connection.MongoConnectionManager.validateConnection(MongoConnectionManager.java:361)
at com.dremio.plugins.mongo.metadata.MongoSchemaFetcherImpl.getMongoVersionFromServer(MongoSchemaFetcherImpl.java:265)
at com.dremio.plugins.mongo.metadata.MongoSchemaFetcherImpl.getState(MongoSchemaFetcherImpl.java:107)
at com.dremio.plugins.mongo.MongoStoragePlugin.getState(MongoStoragePlugin.java:509)
at com.dremio.exec.catalog.ManagedStoragePlugin.lambda$initPlugin$22(ManagedStoragePlugin.java:1417)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
If you have the mongosh client handy, you can try the credentials against the same MongoDB deployment:
$ mongosh --host mongodb0.example.com --authenticationDatabase "admin"\
-u "dremio_mongo_user" -p
Enter password: ****************
Current Mongosh Log ID: 679b1ddd5240fc74c7fe1941
Connecting to: mongodb://<credentials>@mongodb0.example.com:27017/?directConnection=true&serverSelectionTimeoutMS=2000&authSource=admin&appName=mongosh+2.2.12
MongoServerError: Authentication failed.
Cause
In MongoDB, users are associated with a database called their authentication database. If you enter the wrong authentication database for the user when configuring the source in Dremio, it will fail to save with this error.
Steps to Resolve
If you are confident that the username exists in some database in the MongoDB deployment, then reach out to your MongoDB administrator to identify which one.