启动MongoDB
当MongoDB的服务正在运行,刚刚启动的MongoDB shell中执行以下命令:
$ mongo
在shell中,可用的命令列表执行help命令:
> help
它会打印出:
db.help() help on db methods
db.mycoll.help() help on collection methods
sh.help() sharding helpers
rs.help() replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce
show dbs show database names
show collections 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 <db_name> 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 evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
总结
到这里有关在Ubuntu 16.04服务器上安装MongoDB社区版教程就结束了。我们将在以后的教程中将推出更多关于如何在生产环境中使用MongoDB的更多细节。
更多MongoDB相关教程见以下内容:
Linux CentOS 6.5 yum安装MongoDB