Hello All,
I had an application which was communicating with my database properly and without any problem. But when I set a password for the database, it stopped working.
Now, I get
Query failed with error code 13 with name ‘Unauthorized’
error when I run my Springboot apllication.
However, using the shell, I can connect to the database, see the collections, etc.
My MongoDB version is 4.2.0 and I run this command to connect to the database in my shell:
mongo --port 27017 -u “myUsername” -p “myPassword” --authenticationDatabase “admin”
In my Springboot application I have the following URI:
data:
mongodb:
uri: mongodb://myUsername:myPassword@localhost:27017/mainDatabase?authSource=admin&retryWrites=true&w=majority
But it doesn’t work.
Can anyone help me please?