search

Home  >  Q&A  >  body text

如何将MongoDB的collection导出成CVS

我想将MongoDB的collection导出成CVS,在官网文档写可以用mongoexport导出

mongoexport --host localhost --db dbname --collection name --csv > output.csv

但他总警告我指定要导出的字段并无法导出,我要导出所有字段啊,就跟mysql导出cvs那样,怎样忽略他的警告呢?

伊谢尔伦伊谢尔伦2767 days ago548

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-21 11:18:33

    You must add an option to specify the fields you want to export. Mongodb will not select all fields for you by default, so you should add --fields <field1[,field2]>, -f <field1[,field2]> ;…

    reply
    0
  • 怪我咯

    怪我咯2017-04-21 11:18:33

    mongoexport -h localhost -d dbname -c collname -f field1,field2 --csv -o output.csv

    reply
    0
  • Cancelreply