Created
December 11, 2017 12:29
-
-
Save mersanuzun/1cf0e659217bfec20911bda6d5d78d61 to your computer and use it in GitHub Desktop.
Create user and index in Mongodb
This file contains 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
#!/bin/bash | |
# Set variables | |
USERNAME=$MONGODB_USERNAME | |
PASSWORD=$MONGODB_PASSWORD | |
DB_NAME=$MONGODB_DBNAME | |
# Create User | |
mongo $DB_NAME --eval "db.createUser({user: '$USERNAME',pwd: '$PASSWORD',roles: [{role: 'readWrite',db: '$DB_NAME'}]});" | |
# Create Index | |
mongo $DB_NAME --eval "db.someCollection.createIndex({'nsA': 1, 'nsB': 1, 'counterValue': 1});" | |
# Create index | |
mongo $DB_NAME --eval "db.someCollection2.createIndex({'ns': 1, 'js': 1})" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment