How to use mongodump for 1 collection

后端 未结 4 769
小蘑菇
小蘑菇 2021-01-30 00:58

How can I use mongodump to move a single collection from one database to another?

How should I use the command and its options?

4条回答
  •  [愿得一人]
    2021-01-30 01:15

    Very basic commands for dump mongodb.

    1. Dump all collection

      mongodump
      
    2. Dump specific database only

      mongodump --db=DB_NAME
      
    3. Dump database with username & password

      mongodump -u=USERNAME -p=PASSWORD --db=DB_NAME
      
    4. Dump from another host

      mongodump --host HOST_NAME/HOST_IP --port HOST_PORT  --out {YOUR_DIRECTOTY_PATH} --db=DB_NAME
      

    Only able to dump from another host when they allow it.

提交回复
热议问题