Connect with mongosh
Open interactive shell to a MongoDB instance
mongosh 'mongodb://user:pass@mongo:27017/dbname'
More mongodb commands
-
mongosh --eval 'rs.status()' mongodb://mongo:27017Show replica set members, lag, and election status
-
mongosh --eval 'db.stats()' mongodb://mongo:27017/mydbData size, storage size, collection count for a database
-
mongosh --eval 'db.myCollection.stats()' mongodb://mongo:27017/mydbDocument count, index sizes, storage for a collection
-
mongosh --eval 'db.currentOp({active:true,secs_running:{$gt:5}})' mongodb://mongo:27017Show operations running longer than 5 seconds
-
mongodump --uri='mongodb://user:pass@mongo:27017' --db=mydb --out=/backups/Export database to BSON files