gpt4 book ai didi

mongodb - 无法授权新创建的 MongoLabs 数据库

转载 作者:可可西里 更新时间:2023-11-01 09:09:01 26 4
gpt4 key购买 nike

我正在尝试从 MongoLab 开始。使用 mongo shell 似乎我无法对我创建的任何数据库进行授权,即使使用全新的帐户和数据库也是如此。

我使用与数据库用户相同的用户名和密码创建了 MongoLab 用户,因此我确定没有用户名/密码错误。

# connect to mongod v2.4.3 using 2.4.3 client:
#
imac ~/Desktop/mongodb-osx-x86_64-2.4.3/bin$ ./mongo ds059557.mongolab.com:59557/cachv -u redacted -p redacted
MongoDB shell version: 2.4.3
connecting to: ds059557.mongolab.com:59557/cachv
> use mydb
switched to db mydb
> db.things.insert({f:1})
not authorized for insert on mydb.things

# connect to mongod v2.2.4-rc0 using 2.4.3 client:
#
imac ~/Desktop/mongodb-osx-x86_64-2.4.3/bin$ ./mongo dbh83.mongolab.com:27837/cachv2 -u redacted -p redacted
MongoDB shell version: 2.4.3
connecting to: dbh83.mongolab.com:27837/cachv2
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Error while trying to show server startup warnings: need to login
> use mydb
switched to db mydb
> db.things.insert({f:1})
Sat Apr 27 05:46:32.456 JavaScript execution failed: getlasterror failed: { "errmsg" : "need to login", "ok" : 0 } at src/mongo/shell/db.js:L698
> db.auth('redacted','redacted')
Error: 18 { errmsg: "auth fails", ok: 0.0 }
0

第二次尝试:

imac ~/Desktop/mongodb-osx-x86_64-2.4.3/bin$ ./mongo dbh83.mongolab.com:27837/cachv2 -u redacted -p redacted
MongoDB shell version: 2.4.3
connecting to: dbh83.mongolab.com:27837/cachv2
Error while trying to show server startup warnings: need to login

终于下载了老版本的2.2.4客户端,还是不行:

# connect to mongod v2.2.4-rc0 using 2.2.4 client:
#
mac ~/Desktop/mongodb-osx-x86_64-2.2.4/bin$ ./mongo dbh83.mongolab.com:27837/cachv2 -u redacted -p redacted
MongoDB shell version: 2.2.4
connecting to: dbh83.mongolab.com:27837/cachv2
> use mydb
switched to db mydb
> db.things.insert({'g':1})
Sat Apr 27 06:00:30 uncaught exception: getlasterror failed: { "errmsg" : "need to login", "ok" : 0 }
> db.auth('redacted','redacted')
Error: { errmsg: "auth fails", ok: 0.0 }
0
> db.things.insert({'g':1})
Sat Apr 27 06:00:47 uncaught exception: getlasterror failed: { "errmsg" : "need to login", "ok" : 0

是否有任何其他端口必须在我这边打开?

有人能帮忙吗?

谢谢!

达伦

最佳答案

好的!我修好了。

出于某种原因 -u 和 -p 对我不起作用,而且似乎调用 db.auth() 必须作为 first 命令调用连接后在 shell 中。

此外,对于 pymongo,从服务器字符串解析的用户名/密码似乎不起作用,因此我不得不调用 db.authenticate(user, password)。

关于mongodb - 无法授权新创建的 MongoLabs 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16250791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com