Last active
March 9, 2020 17:08
-
-
Save oxlb/2c37f7ba3afea7174f2334202e3cc4b4 to your computer and use it in GitHub Desktop.
Script to create mongoDB multiple database as well users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print('Start #################################################################'); | |
db = db.getSiblingDB('api_prod_db'); | |
db.createUser( | |
{ | |
user: 'api_user', | |
pwd: 'api1234', | |
roles: [{ role: 'readWrite', db: 'api_prod_db' }], | |
}, | |
); | |
db.createCollection('users'); | |
db = db.getSiblingDB('api_dev_db'); | |
db.createUser( | |
{ | |
user: 'api_user', | |
pwd: 'api1234', | |
roles: [{ role: 'readWrite', db: 'api_dev_db' }], | |
}, | |
); | |
db.createCollection('users'); | |
db = db.getSiblingDB('api_test_db'); | |
db.createUser( | |
{ | |
user: 'api_user', | |
pwd: 'api1234', | |
roles: [{ role: 'readWrite', db: 'api_test_db' }], | |
}, | |
); | |
db.createCollection('users'); | |
print('END #################################################################'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment