无法使用Mongo导出查询

Paw*_*wan 10 mongodb

我在Mongo DB中有一个名为" sample " 的收集器和名为" at "的数据库.

db.sample.find().pretty()
{
        "_id" : "35004",
        "city" : "ACMAR",
        "pop" : 6055,
        "state" : "AL"
}
{
        "_id" : "35005",
        "city" : "ADAMSVILLE",
        "pop" : 10616,
        "state" : "AL"
}
{
        "_id" : "35006",
        "city" : "ADGER",
        "pop" : 3205,
        "state" : "AL"
}
Run Code Online (Sandbox Code Playgroud)

我曾尝试使用mongo导出查询,但我没有成功,请让我知道我在哪里做错了.

我尝试过使用以下方法,但总是产生错误.

mongoexport --host localhost --db at --collection "sample" --csv --out text.csv --fields city,state

mongoexport --csv -o /D:/test.csv -d at -c sample -f city,state,pop
Run Code Online (Sandbox Code Playgroud)

我收到以下错误,请帮助

Sun Mar 10 00:25:44 SyntaxError:missing; before statement(shell):1

Joh*_*yHK 35

mongoexport 必须从您的OS命令shell运行,而不是mongo shell.