Last active
September 3, 2018 13:46
-
-
Save johnw86/88b6e872257235bc723e0ac1fe07eeff to your computer and use it in GitHub Desktop.
Mongo shell snippets
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
To be ran against mongo.exe | |
// Start up - specify db file location | |
"PathToMongo.exe" --dbpath C:\mongodb\data | |
// Connect to shell | |
mongo --port 27017 -u "username" -p "password" --authenticationDatabase "admin" | |
Option param --nodb | |
// Select db | |
use databaseName | |
// Can then run commands against db - view help | |
db.help() | |
// Index stats | |
db.createRole({'role': 'indexstats', privileges: [{ resource: { "db": "DBNAME", "collection" : "" }, actions: [ "indexStats" ] }], roles: []}) | |
db.grantRolesToUser('DBUSER', ['indexstats']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment