I’m trying to secure mongodb by following the link
https://www.digitalocean.com/community/tutorials/how-to-secure-mongodb-on-ubuntu-20-04
But it isn’t working. -I’m on step 1:.
This is what happens
db.createUser(
... {
... user: "Adam",
... pwd: passwordPrompt(),
... roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
... }
... )
Enter password:
uncaught exception: Error: couldn't add user: Could not find role: readWriteAnyD atabase@test :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1367:11
@(shell):1:1
What went wrong?
Does this mean the mongodb installation is broken? I followed the digital ocean link https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-20-04
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi,
This does not mean that MongoDB is broken. I have run the same command and it was successful.
I would suggest you to try creating use with a single role.
Regards, Rajkishore