MongoDB Shell
-
帮助
help db.help()
-
启动shell
mongo
-
显示数据库
show dbs;
-
进入数据库
use <db>;
-
显示数据集
show collections;
-
显示前10条数据
db.<collection>.find().limit(10)
-
插入数据
db.<collection>.insert()
-
删除列
db.<collection>.update({},{$unset:{"<col>":""}},{multi:true});
-
备份数据库
mongodump -h dbhost -d dbname -o dbdirectory
-
恢复数据库
mongorestore -h dbhost -d dbname --directoryperdb dbdirectory