當(dāng)mongodb 數(shù)據(jù)庫(kù)打開了 auth認(rèn)證 以后 就不能直接使用 dump 而需要提供對(duì)應(yīng)的賬號(hào)密碼 如下
mongodump -h localhost:27017 -d test -u test -p testpwd -o D:\dump
-h 地址
-d 數(shù)據(jù)庫(kù)名稱
-u 用戶名
-p 密碼
-o 輸出地址
--authenticationDatabase admin 驗(yàn)證賬戶的數(shù)據(jù)庫(kù)
恢復(fù)數(shù)據(jù)庫(kù)
mongorestore -h localhost:27017 -d test -c order --dir d:\dump\test\test.bson -u Aibol -p Secret01!
-c 集合名詞

image.png