mongo Shell
启动
mongo “mongodb://mongodb0.example.com:28015”
mongo --host mongodb0.example.com --port 28015
mongo --username alice --password --authenticationDatabase admin --host mongodb0.examples.com --port 28015
shell command
db.currentOP()
use myNewDatabase
db.myCollection.insertOne( { x: 1 } );
db.myCollection.find().pretty()
db.help()
db..help()
show collections
show users
show profile
db.people.find( { user_id: { $regex: /bc/ } } ) 相当于 WHERE user_id like “%bc%”
db.people.find( { status: “A”, age: 50 }) 相当于 SELECT * FROM people WHERE status = “A” AND age = 50
工具
mongoimport --db test --file ./products.json
mongotop
mongostat