Unable to connect to mongohq at heroku using shell

牧云@^-^@ 提交于 2019-12-24 05:05:22

问题


I installed mongohq:sandbox at Heroku. When I want to connect to mongo, it occurs an error:

mongo linus.mongohq.com:10123/app10575123 -u my_user -p pwd123
MongoDB shell version: 2.2.2
connecting to: linus.mongohq.com:10123/app10575123
> show dbs
Wed Jan  9 06:00:50 uncaught exception: listDatabases failed:{ "errmsg" : "need to login", "ok" : 0 }

Login and password are correct.


回答1:


You are connected to the database, but for the shared database plans at MongoHQ (especially the sandbox ones), for security reasons, they do not include admin-level access to the Mongo instance ... only access to your actual database.

"show dbs" is an admin-level command and, in this case, would show other databases on that sandbox MongoDB process.

Instead, you will want to use commands like:

  • show collections
  • db.[collection_name].findOne()
  • db.stats()
  • db.[collection_name].stats()
  • db.[collection_name].ensureIndex({foo:1, bar:1}, {background:true})

... and so on.

I hope this helps!




回答2:


You should be able to show collections, but show dbs requires admin privileges.



来源:https://stackoverflow.com/questions/14225576/unable-to-connect-to-mongohq-at-heroku-using-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!