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

时间:2015-06-05 17:49:15   收藏:0   阅读:2890

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


MongoDB 2.4.10 使用admin数据库下的xucy管理员帐号导出数据,验证失败。

# mongoexport -uxucy -p -d Test -c Pro -f _id,SK2,SK3 -o /data/var/log/mongodb/pro.json   
connected to: 127.0.0.1    
Enter password:     
assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }


解决方法:

这个是2.2.2版本以后出现的,参考:https://jira.mongodb.org/browse/SERVER-9991


需要加入验证参数:  

--authenticationDatabase admin


类似的命令有mongodump、mongorestore、mongoexport、mongoimport

# mongoexport --authenticationDatabase admin -uxucy -p -d Test -c Pro -f _id,SK2,SK3 -o /data/var/log/mongodb/pro.json   
connected to: 127.0.0.1    
Enter password:     
exported 564097 records


本文出自 “SQL Server Deep Dives” 博客,请务必保留此出处http://ultrasql.blog.51cto.com/9591438/1658881

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!