mongod 一些命令汇总

1. 导出数据库:

mongoexport -d master -c reports -o no.json --type json -f "title,name" -q '{"name":"vic"}'  -u 账户 -p 密码 --authenticationDatabase admin

            -d :数据库名

            -c :collection名

            -o :输出的文件名

            --type : 输出的格式,默认为json

            -f :输出的字段,如果-type为csv,则需要加上-f "字段名"
       -q : 查询条件

 1.2 导入数据

mongoimport  --port 27017 -d 数据库 -c 表 --file in.json -u 账号-p 密码 --authenticationDatabase admin

2.创建索引:

语法中 Key 值为你要创建的索引字段,1 为指定按升序创建索引,如果你想按降序来创建索引指定为 -1 即可。
db.col.createIndex({"title":1,"description":-1})

原文地址:https://www.cnblogs.com/myvic/p/10600748.html