How do I export/dump mongodb database?

后端 未结 2 403
野趣味
野趣味 2020-12-08 02:41

I tried a mongo export like this:

./mongodump --db local --collection lecturer 

and then I tried:

./mongodump --db  local -         


        
相关标签:
2条回答
  • 2020-12-08 03:34

    How to backup and restore databases

    Start Mongo, open a new tab in terminal. First navigate to the folder where you want to save the backup, then type the following command.

    Backup single database:

    mongodump --host localhost --port 27017 --db db_name
    

    Restore single database:

    mongorestore --host localhost --port 27017 --db **** dump/db_name
    

    (In this case, **** represents UserDefinedName for the database > mydb dump/db_name > this will import dump db into mydb)

    Backup all databases:

    mongodump --host localhost --port 27017
    

    Restore all databases:

    mongorestore --host localhost --port 27017  dump
    
    0 讨论(0)
  • 2020-12-08 03:40

    mongodump is a command-line utility and it's supposed to be run from the system command prompt, not the mongo javascript shell.

    ./mongodump --db local --collection lecturer
    

    if successful, this command will create some files under dump directory in the current dir.

    0 讨论(0)
提交回复
热议问题