? show collections in current database
? ? ? ? show users? ? ? ? ? ? ? ? ? show users in current database
? ? ? ? show profile? ? ? ? ? ? ? ? show most recent system.profile entries with time >= 1ms
? ? ? ? show logs? ? ? ? ? ? ? ? ? ? show the accessible logger names
? ? ? ? show log [name]? ? ? ? ? ? ? prints out the last segment of log in memory, 'global' is default
? ? ? ? use ? ? ? ? ? ? ? ? set current database
? ? ? ? db.foo.find()? ? ? ? ? ? ? ? list objects in collection foo
? ? ? ? db.foo.find( { a : 1 } )? ? list objects in foo where a == 1
? ? ? ? it? ? ? ? ? ? ? ? ? ? ? ? ? result of the last line eva luated; use to further iterate
? ? ? ? DBQuery.shellBatchSize = x? set default number of items to display on shell
? ? ? ? exit? ? ? ? ? ? ? ? ? ? ? ? quit the mongo shell
> db.getCollection("version");
test.version
> exit
bye
三、mongodb相关工具
###在安装文件下有README,描述了常用的mongodb相关命令行工具
# more /usr/local/mongodb/README
MongoDB README
Welcome to MongoDB!
COMPONENTS
? bin/mongod - The database process.
? bin/mongos - Sharding controller.
? bin/mongo? - The database shell (uses interactive java script).
UTILITIES
? bin/mongodump? ? ? ? - MongoDB dump tool - for backups, snapshots, etc..
? bin/mongorestore? ? ? - MongoDB restore a dump
? bin/mongoexport? ? ? - Export a single collection to test (JSON, CSV)
? bin/mongoimport? ? ? - Import from JSON or CSV
? bin/mongofiles? ? ? ? - Utility for putting and getting files from MongoDB GridFS
? bin/mongostat? ? ? ? - Show performance statistics
RUNNING
? For command line options invoke:
? ? $ ./mongod --help
? To run a single server database:
? ? $ mkdir /data/db
? ? $ ./mongod
? ? $
? ? $ # The mongo java script shell connects to localhost and test database by default:
? ? $ ./mongo
? ? > help
DRIVERS
? Client drivers for most programming languages are available at mongodb.org.? Use the
? shell ("mongo") for administrative tasks.
###获取单个命令用法
# --help
# mongod --help|more
Options:
General options:
? -h [ --help ]? ? ? ? ? ? ? show this usage information
? --version? ? ? ? ? ? ? ? ? show version information
# mongod --version
db version v3.0.6
git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2?
更多MongoDB相关内容可以看看以下的有用链接:?