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

来源:互联网 发布:出国留学知乎 编辑:程序博客网 时间:2024/06/12 01:30

当开启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,实际生产环境,最好新建账号作业


windows下也遇到过类似错误,原因是.bat里面密码处引用了''(单引号号);

2 0