Skip to content

Instantly share code, notes, and snippets.

@johnw86
Last active September 3, 2018 13:46
Show Gist options
  • Save johnw86/88b6e872257235bc723e0ac1fe07eeff to your computer and use it in GitHub Desktop.
Save johnw86/88b6e872257235bc723e0ac1fe07eeff to your computer and use it in GitHub Desktop.
Mongo shell snippets
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