Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Schevus
Contributor
Contributor

Connecting To MongoDB 6 with SCRAM-SHA-256

Has anyone successfully configured a connection to MongoDB 6 with SCRAM-SHA-256? I am able to force SHA-256 by setting the authMechanism advanced attribute, but I am getting "Not authorized to query database", even though the account works through other clients.

Labels (2)
1 Reply
diegozecchini
Specialist
Specialist

Hi
If you're encountering a "Not authorized to query database" error when connecting Qlik to MongoDB 6 with SCRAM-SHA-256 authentication, here are some troubleshooting steps to address the issue:

Ensure the user account you're using has the correct roles and privileges for the database you're trying to query. You can check the roles assigned to the user with the following command in MongoDB:

db.getUser("your_username")
Verify that the user has at least the read role (or higher, such as readWrite) for the target database.

MongoDB often uses the admin database for authentication. Ensure that your connection string or settings specify the correct authSource:

If the user was created in the admin database:
mongodb://username:password@host:port/database?authSource=admin

If the user was created in a specific database:
mongodb://username:password@host:port/database?authSource=database_name

Connect to MongoDB using the mongo shell to confirm that the credentials and authentication mechanism are working:
mongo --username your_username --password your_password --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-256

If this fails, there may be an issue with the credentials or user setup.