使用shell命令

时间:2016-05-09 11:26:21

标签: mongodb shell mongo-shell

当我从OS shell连接时,

mongo --port 27017 -u "testusr" -p "testpwd"  --authenticationDatabase "testdb"

而不是将我带到testdb,它总是将我登录到测试数据库? 我在这里缺少什么?

db.auth("testusr","testpwd")正在处理任何身份验证问题? 如何重定向到正确的数据库?

1 个答案:

答案 0 :(得分:1)

以下为我工作

mongo localhost:27017/testdb -u "user" -p "pass"  --authenticationDatabase "testdb"

你可以找到帮助(我在linux中使用)

mongo --help
usage: mongo [options] [db address] [file names (ending in .js)]
db address can be:
foo                   foo database on local machine
192.169.0.5/foo       foo database on 192.168.0.5 machine
192.169.0.5:9999/foo  foo database on 192.168.0.5 machine on port 9999