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})

mongod 一些命令汇总

 

相关文章:

  • 2021-12-22
  • 2021-05-03
  • 2021-08-15
  • 2021-07-15
  • 2022-03-05
  • 2021-06-12
猜你喜欢
  • 2022-12-23
  • 2021-12-27
  • 2021-09-13
  • 2022-12-23
  • 2022-02-16
  • 2021-09-08
  • 2021-12-05
相关资源
相似解决方案