您的位置:首页 > 大数据 > 人工智能

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

2015-06-05 14:45 405 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: