How to import dump folder into mongodb database?

雨燕双飞 提交于 2021-02-06 09:56:05

问题


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:

  1. Open a terminal and go to your Home directory
  2. Create a folder with name dump and add your folder which you want to add.
  3. Write command mongorestore and enter it will restore all your documents.
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!