(1)mongoexport命令
例如:
mongoexport –db testdb —collection person —out person.json
mongoexport –db testdb —collection person —fields name,age —out person.json
mongoexport –db testdb —collection person —query ‘{“name“:”tom”}’ —out person.json
mongoexport –db testdb —collection person —sort {“age”:1} —type csv —fields name,age —out person.csv
mongoexport –db testdb —collection person —limit 1 —skip 1 —out person.json
(2)mongodump命令
mongodump —host [ip] –port [p] —username [u] —password [p] –db [db] —collection [c] —query [query] —out [目录] –gzip
其中,–gzip表示使用Gzip压缩存档
例如:
mongodump –db testdb —out /home –gzip
(3)mongorestore命令
mongorestore —host [ip] –port [p] —username [u] —password [p] –db [db] —collection [c] —dir [目录] —drop –gzip
其中,–drop表示导入前删除数据库中集合
例如:
mongorestore –db testdb —dir testdb —drop –gzip
本文介绍: mongodump —host [ip] —port [p] —username [u] —password [p] —db [db] —collection [c] —query [query] —out [目录] —gzip。mongorestore —host [ip] –port [p] —username [u] —password [p] —db [db] —collection [c] —dir [目录] —drop —gzip。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。