Use mongoexport to export data in JSON format from MongoDB to local

Order

mongoexport --host 127.0.0.1 --port 27017 \
	--username root --password 123456 \
	--db demo_db --collection demo_collection \
	--type json --out $PWD/result.json \
	-q '{"create_time":{"$gte":{"$date":"2020-03-04T16:00:00Z"},"$lt":{"$date":"2020-03-05T16:00:00Z"}}}'

illustrate:

  • --host, --port, --username, --passwordspecify the data source host, port, user name, password
  • --dbSpecify the library name
  • --collectionSpecified collection name
  • --typeSpecify the export format as JSON
  • --outSpecify the export path
  • -qSpecify filter criteria

Guess you like

Origin blog.csdn.net/xchenhao/article/details/130577139