简体   繁体   English

如何为MongoDB erlang驱动程序指定用户/密码?

[英]How to specify user/password for MongoDB erlang driver?

This driver is used: https://github.com/mongodb/mongodb-erlang 使用此驱动程序: https : //github.com/mongodb/mongodb-erlang

I was not able to connect to my mongodb (mongolab) because I cannot set my username:password I've tried username:pass@mongoserver but that crushes the application. 我无法连接到mongodb(mongolab),因为无法设置我的用户名:密码,但我尝试过用户名:pass @ mongoserver,但这使应用程序崩溃。

When I don't set anything it says that I have no permissions for write. 当我没有设置任何内容时,它表示我没有写权限。

UPD 1: UPD 1:

So here are new errors 所以这是新的错误

`main(_) -> application:start (bson), application:start (mongodb), `main(_)-> application:start(bson),application:start(mongodb),

Host = {"myname.mongolab.com", 53798},

{ok, Connection} = mongo:connect(Host),

ok = mongo:do(safe, master, Connection, micomico, fun() ->
           mongo:auth(<<"micomico">>,<<"password">>),
           mongo:insert (teams, {x,1, y,2})
    end).

` `

and the result is: exception error: no match of right hand side value {failure, {write_failure,16544, <<"not authorized for insert on micomico.teams">>}} UPD2 Finally I was able to do queries with mentioned code. 结果是: exception error: no match of right hand side value {failure, {write_failure,16544, <<"not authorized for insert on micomico.teams">>}} UPD2的exception error: no match of right hand side value {failure, {write_failure,16544, <<"not authorized for insert on micomico.teams">>}}最后,我能够使用上述代码进行查询。

https://github.com/ChicagoBoss/mongodb-erlang-mongodb-erlang驱动程序的此fork提供mongo:authmongo:add_user函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM