I have created a user in the admin db with the following command:
db.createUser({user: 'username', pwd: 'pass', roles: [ { role: 'root', db: 'admin' }] });
After I added the command in mongod.conf as follows:
security:
authorization: enabled
I am connecting to the MongoDB from spring boot and my connection in the yml as follows:
data:
mongodb:
authentication-database: admin
database: test_db
host: host
password: pass
port: 27017
username: username
but when I run the program I get an error saying the follows:
Caused by: com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized on test_db to execute command { find: "system.indexes", filter: { ns: "test_db.dbchangelog", key: { changeId: 1, author: 1 } }, limit: 1, singleBatch: true, $db: "test_db" }' on server host:27017
Can anyone able to help me to reslove this issue?