其實導入導出GridFS和其他集合一樣,只是GridFS有files和chunks兩個
1.進入bin目錄;
2.導出GridFS數據:
./mongodump --db test-db --collection userImage.files --out ./userImg
./mongodump --db test-db --collection userImage.chunks --out ./userImg
3.導入GridFS數據
./mongorestore --db test-db --collection userImage.files /路徑/userImage.files.bson
./mongorestore --db test-db --collection userImage.chunks /路徑/userImage.files.bson
test-db爲數據庫名
userImage.files爲要導出的數據對象
./userImg 指定數據存放的文件夾