You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting up a user and db (other than the admin user and test db) is a little opaque.
This link How to create a DB for MongoDB container on start up? with over 268K views shows how much of an issue the lack of documentation is. There are many other variations of the search term above, so I'd imagine the numbers would be a lot higher if they were all tallied.
Proposal
Please include something like the below in that section of the documentation
print('Init Script - Started Adding the User Roles.');// use the admin db to create a new user and give that new user permission to the db// mongo seems to lazy load the db, meaning it'll create the db when a collection is first added// but the newly created user will still have access to the dbdb=db.getSiblingDB('admin');db.createUser({user: '<custom user>',pwd: '<custom user password>',roles: [{role: 'readWrite',db: '<custom db>'}],});print('Init Script - Ended Adding the User Roles.');
please include the shell version
The text was updated successfully, but these errors were encountered:
@melvingaye so its mandatory to do the db.getSibilings()? I don't understand it, if i have to specify the custom db in the script, what's the point to use the MONGO_INITDB_DATABASE environment variable in the first place?
Problem
Setting up a user and db (other than the admin user and test db) is a little opaque.
This link How to create a DB for MongoDB container on start up? with over 268K views shows how much of an issue the lack of documentation is. There are many other variations of the search term above, so I'd imagine the numbers would be a lot higher if they were all tallied.
Proposal
Please include something like the below in that section of the documentation
docker-compose.yaml
mongo-init.js
The text was updated successfully, but these errors were encountered: