There appears to be no way to exclude a field (such as _id
) using mongoexport.
Here's an alternative that has worked for me on moderate sized databases:
mongo myserver/mydb --quiet --eval "db.mycoll.find({}, {_id:0}).forEach(printjson);" > out.txt
On a large database (many millions of records) it can take a while and running this will affect other operations people try to do on the system:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…