MongoDB备份与导入

导出mongodb的数据

mongodump -d nodes -o url

 

导入mongodb数据
mongorestore --db nodes url

 

删除mongodb的数据库
db.dropDatabase()

 

删除db之后需要创建用户,如下

> db.createUser({

... user: 'admin',
... pwd: '123456',
... roles: [
... 'dbAdmin'
... ]
... })

 

单表导入:

mongoimport -d dbname -c collectionname url

条件导出

mongoexport -d testdb -c mtb1 -q '{name:"joe"}' -o mtb1.dmp

 

nodes为schema的名称

url为导入导出的文件夹名称
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

 

posted @ 2015-11-24 13:47  VoctrALs  阅读(192)  评论(0编辑  收藏  举报