我尝试部署我的应用Node.js + MongoDB。
我在Heroku上部署了我的应用程序。 Added add-ons Mongolab to app
打开我的数据库并创建新用户名:dima;密码:***(添加数据库用户)。
然后我尝试连接到DB:
我的控制台:
mongo ds039135.mongolab.com:39135/heroku_xkbthxdx -u dima -p ***
MongoDB shell版本:2.4.9
连接至:ds039135.mongolab.com:39135 / robi_xkbthxdx
2月19日星期五19:26:50.181错误:18 {ok:0.0,errmsg:" auth失败",代码:18}在src / mongo / shell / db.js:228
例外:登录失败
这有什么缺失?谢谢!
答案 0 :(得分:1)
您的>>> random_nums = np.array([-1, 0, 1, 2, 3])
>>> probabilities = np.array([0.01, 0.3, 0.58, 0.1, 0.01])
>>> target = dict(zip(random_nums, probabilities))
>>> {k: round(v, 2) for k, v in target.items()}
{0: 0.29999999999999999, 1: 0.57999999999999996, 2: 0.10000000000000001, 3: 0.01, -1: 0.01}
>>> {k: round(float(v), 2) for k, v in target.items()}
{0: 0.3, 1: 0.58, 2: 0.1, 3: 0.01, -1: 0.01}
shell版本是2.4.9。目前,所有MongoLab Sandbox数据库都是版本3.
将mongo
shell升级到3.x.y - 最好是在客户端和服务器之间匹配主要版本,MongoDB可能对主要版本差异很敏感。例如:使用3.0.x shell与3.0.x服务器,2.6.x shell与2.6.x服务器等
编辑 - 添加"为什么":从3.0开始,默认的身份验证机制是SCRAM-SHA-1,2.4 mongo
shell不支持,因此身份验证失败。< / p>
答案 1 :(得分:1)
然后,如果您的用户/通行证有任何问题,您可以通过以下方式获取数据库用户名和密码:
heroku config | grep MONGODB_URI
回复的形式为:
MONGOLAB_URI: mongodb://username:password@mlab.com:12345/db