# id 不大于2的
mongoexport --port 10510 -d test -c col -q '{id : {$lte:2}}' --out ./names1.txt
# id 在2和4之间的
mongoexport --port 10510 -d test -c col -q '{id : {$gt:2} , id :{$lte:4}}' --out ./names2.txt
# id大于4的
mongoexport --port 10510 -d test -c col -q '{id : {$gt:4}}' --out ./names3.txt
你可以写个脚本,试试。
说明:-d 是指定database ,-c 指定 集合 ,-q 是查询,后面的文件格式支持json、cvs、txtThe format is
rrreee
🎜Give me a chestnut🎜
🎜The database is test, and collections is col. The data inside is as follows🎜
rrreee
🎜Now exported in three equal files. 🎜
rrreee
🎜You can write a script and try it. 🎜
🎜Note: -d specifies database, -c specifies collection, -q specifies query, and the following file formats support json, cvs, txt🎜🎜
Generally speaking, data of 180w... does not need to be divided. The principles for selecting Shard keys are actually explained in detail in the official documentation. If you want to know more, you may wish to refer to it.
Use the tools that come with mongo
Use mongo’s own tools to export to
json
orcvs
ortxt
format.json
或者cvs
或者txt
格式.格式为
举个栗子
数据库为
test
,collections
为col
。里面的数据如下现在平均分成三个文件导出。
你可以写个脚本,试试。
说明:-d 是指定database ,-c 指定 集合 ,-q 是查询,后面的文件格式支持
rrreee 🎜Give me a chestnut🎜 🎜The database isjson、cvs、txt
The format istest
, andcollections
iscol
. The data inside is as follows🎜 rrreee 🎜Now exported in three equal files. 🎜 rrreee 🎜You can write a script and try it. 🎜 🎜Note: -d specifies database, -c specifies collection, -q specifies query, and the following file formats supportjson, cvs, txt
🎜🎜Generally speaking, data of 180w... does not need to be divided.
The principles for selecting Shard keys are actually explained in detail in the official documentation. If you want to know more, you may wish to refer to it.