目錄
http://www.mongodb.org/
# mongorestore -u yourdb dump/ Enter password: 2017-06-09T11:55:58.566+0800 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.
# mongorestore -u yourdb -d yourdb dump/yourdb
> use admin switched to db admin > db.addUser('neo','chen') { "user" : "neo", "readOnly" : false, "pwd" : "68ace374737253d87e0ec91d4fcb673d" } > db.system.users.find() { "_id" : ObjectId("4c481404b9db6474d2fcb76f"), "user" : "neo", "readOnly" : false, "pwd" : "68ace374737253d87e0ec91d4fcb673d" } > db.auth('neo','chen') 1
[root@ecs-3705 ~]# mongorestore dump/ 2018-11-05T11:48:08.981+0800 preparing collections to restore from 2018-11-05T11:48:08.982+0800 Failed: netkiller.assets: error reading database: command listCollections requires authentication
需要認證,請使用 -u 用戶名 -p 密碼 -d 資料庫 來恢復
[root@netkiller ~]# mongorestore -h 127.0.0.1 -u netkiller -p netkiller -d netkiller dump/netkiller/