当开启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里面密码处引用了''(单引号号);
本文介绍了解决MongoDB在进行备份操作时出现的认证失败问题。通过指定--authenticationDatabase参数,可以有效避免mongodump和mongorestore过程中因认证问题导致的任务失败。建议在生产环境中使用专门的账号进行备份作业。
1万+

被折叠的 条评论
为什么被折叠?



