首页 > 代码库 > assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }

assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }

当开启auth后,执行mongodump,mongorestore时有如下错误”assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }“

其实就是认证失败嘛

执行mongodump --help后发现问题,添加authenticationDatabase就好了

#mongodump -u root -p passwd--authenticationDatabase admin -d test -o /mnt/mongdb

mongorestore -u root -p passwd --authenticationDatabase admin -d test  /mnt/mongdb

备注,如果测试用,最好使用--authenticationDatabase admin,实际生产环境,最好新建账号作业

assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }