问题
I have created a mongo dump
from a remote server and .bson and .metadata files stored in to a folder.
I want to import
this folder into my local mongodb
. I am using robomongo
as a mongodb client ui
.
I got some command which are importing json files one by one but I want import
all the files at a time by robomongo or cmd.
回答1:
mongodump
is a util for creating a binary export of the database. mongodump
is used in conjunction with mongorestore
as a backup strategy.
If you wanted to restore your mongodump
then you would need to use mongorestore
Or,
You could take an export with mongoexport and then use mongoimport
回答2:
Try with this:
mongorestore -d db_name dump_folder_path
回答3:
Go to relevant folder where dump is located by terminal
mongorestore --host localhost --port 27017 --db [DB_name_in_mongodb] dump/[DB_name_in_dump]
回答4:
Sharing steps for ubuntu users:
- Open a terminal and go to your Home directory
- Create a folder with name dump and add your folder which you want to add.
- Write command
mongorestore
and enter it will restore all your documents.- Open your
robomongo
and connect with the localhost and refresh.
Your new documents start reflecting now. Enjoy :)
来源:https://stackoverflow.com/questions/48682173/how-to-import-dump-folder-into-mongodb-database