Mongodump backing up the database

Source: Internet
Author: User
Tags mongodump mongorestore

1:mongodump-h IP--port Port-u user name-p password-d database-o file exists path

If there is no user who can remove-u and-P.
If you export the native database, you can remove-H.
If it is the default port, you can remove--port.
If you want to export all databases, you can remove-D.

Export the specified database: (at this point, just export all the collections under YDKT, but no data for the collection Space time)

127.0. 0.1 -D ydkt-o/tmp/mongdb-tmp

2:mongorestore Restoring a Database

Mongorestore-h IP--port Port-u user name-p password-d database--drop file exists path

To restore the specified database:

[Email protected]:mongo-tmp# mongorestore-d ydkt ydkt/

3:mongoexport Export a table, or some field in a table

Mongoexport-h IP--port Port-u user name-p password-D database-C table name-F field-Q conditional export--csv-o file name

To export an entire sheet:

[Email protected]:mongodb# mongoexport-d ydkt-c bjs-o/tmp/mongdb-tmp/127.0. 0.1  1 Records

4:mongoimport Import Collection (table), or partial fields in a table

[Email protected]:ydkt-c# mongoimport-d ydkt-c BJS--20t11::  58.051+0800    connected to:localhost- -20t11:: 58.054+0800    1  document[email protected]:ydkt

Mongodump backing up the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.