Import and export use HNDB;
Db.s.save ({name: ' John Doe ', age:18,score:80,address: ' Zhengzhou '});d B.s.save ({name: ' Lie Triple ', age:8,score:50,address: ' Zhengzhou '}); Db.s.save ({name: ' Zhang San ', age:38,score:20,address: ' Tianjin ');d b.s.save ({name: ' Zhao Liu ', age:28,score:70,address: ' Zhengzhou '}); Db.s.save ({name: ' King 55 ', age:19,score:90,address: ' Beijing '});
Export only Name field old Mongoexport localhost:27017/admin-d hndb-c s-u admin-p admin-o c:\s.json-f Name
New only export name,agemongoexport/h localhost/port 27017/authenticationdatabase:admin/u admin/p admin/d hndb/c s/o c:\j.js /F Name,age
Export All Properties mongoexport/h localhost/port 27017/authenticationdatabase:admin/u admin/p admin/d hndb/c s/o c:\j.js
Data import old mongoimport-d shop-c student-u user-p shop--directoryperdb C:\student.json
mongoimport/h localhost/port 27017/authenticationdatabase:admin/u admin/p admin/d hndb/c s C:\j.js
Delete database, db.dropdatabase (); Backup and restore export help to local
F:\mongodb\bin>mongodump.exe --help >f:/mongodump-help.txt
F:\mongodb\bin>mongorestore.exe --help >f:/mongorestore-help.txt
Backup mongodump/h localhost/port 27017/u admin/p 123/authenticationdatabase:admin/d hndb/o c:/
Backing up the specified library specifies the table HNDB collection s compressed backup mongodump/h localhost/port 27017/u admin/p 123/authenticationdatabase:admin/d hndb/c s/o C: //gzip
Backing up the specified library specifies the table hndb all information back to the C:/hndb.zip file mongodump/h localhost/port 27017/u admin/p 123/authenticationdatabase:admin/d H Ndb/archive:c:/hndb.zip
Recovery mongorestore/h localhost/port 27017/u admin/p 123/authenticationdatabase:admin/d hndb/dir c:/hndb/
Restore the specified backup, gzip format mongorestore/h localhost/port 27017/u admin/p 123/authenticationdatabase:admin/d hndb/dir:c:/hndb// Gzip
Recover hndb All information from file c:/hndb.zipmongorestore/h localhost/port 27017/u admin/p 123/authenticationdatabase:admin/d hndb/a Rchive:c:/hndb.zip
Export of databases
F:\mongodb\bin>mongodump /h localhost /port 27017 /u admin /p admin /authentica
tionDatabase:admin /d hndb /o c:/
Delete Table > Db.book.drop (); True Delete library > db.dropdatabase (); {"Dropped": "Hndb", "OK": 1} Delete the library table, then back up the recovery
F:\mongodb\bin>mongorestore /h localhost /port 27017 /u admin /p admin /authent
icationDatabase:admin /d hndb /dir c:/hndb/
Export of compressed files
备份指定库指定表 hndb 所有信息 备份到c:/hndb.zip文件中
mongodump /h localhost /port 27017 /u admin /p admin /authenticationDatabase:admin /d hndb /archive:c:/hndb.zip
Delete a library table, import a compressed file
recovery hndb All information From file c :/ hndb . zip
mongorestore /h localhost /port 27017 /u admin /p admin /authenticationDatabase:admin /d hndb /archive:c:/hndb.zip
Export only Stu compressed files into hndb
F : \mongodb\b in > mongodump / h localhost / port 27017 / u admin / Span class= "PLN" >p admin / authentica
tionDatabase:admin /d hndb /c stu /o c:/ /gzip
Restores the specified backup, gzip format
恢复指定的备份,gzip格式
mongorestore /h localhost /port 27017 /u admin /p admin /authenticationDatabase:admin /d hndb /dir:c:/hndb/ /gzip
From for notes (Wiz)
MongoDB Backup recovery Import and export