0

I have MongoDB set up on my laptop for a MEAN Stack university class I'm taking this semester, but of course I don't know what databases I'll be creating for the class, nor how many.

I found this SO question about adding users to MongoDB, and I have a regular user for myself for non-admin stuff. From what I can see in the answer to that question, and from this page of the Mongo documentation, it is not possible to create a user that can read a database that is to be created in the future. Is this indeed the case, or is there some hard-to-find way around it?

1 Answer 1

0

The permissions do not need to reference existing databases. For a role that has read access to most databases, see https://docs.mongodb.com/manual/reference/built-in-roles/#mongodb-authrole-readAnyDatabase.

You may be confused with the concept of auth source/authentication database in MongoDB. Users may be defined in the admin database which bypasses the issue of them referencing databases that don't exist yet.

Sign up to request clarification or add additional context in comments.

2 Comments

If I need to create databases for class, which I assume I will, shouldn't I instead be using readWriteAnyDatabase? Or is that a bad idea? Indeed, I don't really know what I'm doing. I'm not as familiar with Mongo as MySQL (even still not that familiar), so I might not be finding the right resources.
For testing purposes on a development computer you do not need authentication at all. If your class requires specific permissions and users, do whatever the requirements are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.