MongoDB Learning Notes < seven >

Source: Internet
Author: User
Tags mongodump

Continue the learning of MongoDB

1. Export data (interrupts other operations)

Export the Books collection from the database test

operate under the terminal

mongoexport-d test-c Books-o/home/hadoop/desktop/books.json

2. Import data (interrupt other operations)

Also operate under the terminal

Mongoimport--db Test--collection Books--file/home/hadoop/desktop/books.json

3. Run-time backup Mongodump

Operation under the terminal

Export the test database under 27017 of the 127.0.0.1 server

Mongodump--host 127.0.0.1:27017-d Test-o/home/hadoop/desktop/test

4. Run-time recovery Mongorestore

Operation under the terminal

Mongodump--host 127.0.0.1:27017-d Test-directoryperdb/home/hadoop/desktop/test/test

5. Lock operation

Db.runcommand ({fsync:1,lock:1})

6. Unlocking operation

Db.currentop ()

7. Data Repair

Db.repairdatabase ()

8. Add Users

Db.adduser ("Xiaoming", "123")

9. Delete a user

Db.system.users.remove ({User: "Xiaoming"})


MongoDB Learning Notes < seven >

Related Article

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.