質問

I type

`mongo`

in terminal it connects to mongodb. I have many database and collection there. I want to export my

 `hero` (dbs name)

and its collection

users

to a desktop in new folder. By copying that folder and paste in another computer, I want to import that

`hero(dbs name)`

and its collection. Now when i type

show dbs 

then there should be

`hero`

in my second computer. How can i do this. I use mongodump also. can anyone give me the idea?

役に立ちましたか?

解決

This is a good manual page from 10gen showing example commands and what not for doing what you want: http://docs.mongodb.org/manual/administration/backups/#database-dumps and http://www.mongodb.org/display/DOCS/Import+Export+Tools#ImportExportTools-mongodump .

So an example for you would be (to copy the collection):

mongodump --collection hero --database name

And then to restore it on the other computer after copying the output of the above command to the current folder where mongorestore is held:

mongorestore --collection hero --database name

I am unsure what OS you are using as such I have placed these in Linux command syntax.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top