mongodb show dbs listDatabases failed

2020-07-28 11:19发布

问题:

I am new to mongo db. I just installed mongo DB on my MAC,

After watching this Youtube Video

https://www.youtube.com/watch?v=pWbMrx5rVBE&t=369s

In mongo shell, I entered show dbs and I get wired output. Kindly help me to understand and solve this

> show dbs
2017-09-11T02:45:34.298+0530 E QUERY    [thread1] Error: listDatabases failed:{
    "ok" : 0,
    "errmsg" : "unable to open cursor at URI statistics:table:collection-2-2362555297355466682. reason: No such file or directory",
    "code" : 43,
    "codeName" : "CursorNotFound"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
shellHelper.show@src/mongo/shell/utils.js:769:19
shellHelper@src/mongo/shell/utils.js:659:15
@(shellhelp2):1:1

回答1:

After a couple of research, I found the solution and sharing all I learned so no new learner struggles like me.

My mistake :

I was staring mongodb using :

mongod --config "c:\MongoDB\Mongod.cfg"

and start mongo shell by just running

 mongo

Starting Mongo DB and Shell

Then understood, what each command does :

|*| Start Mongo DB with default config :

    mongod

|*| Start Mongo DB with config file :

        mongod -f "c:\MongoDB\Mongods.cfg"
    |Or| 
        mongod --config "c:\MongoDB\Mongod.cfg"

|O| Start Mongo DB with config flags :

    mongod --dbpath "c:\mongodb\data\nameMdb" --logpath "c:\mongodb\log\nameMdbLog.log" --directoryperdb --logappend

So correspondingly we should use mongo also to start shell :

|*| Start Mongo shell with default config :

    mongo

|*| Start Mongo shell with localhost config flags :

    mongo --host localhost --port 28888

|*| Start Mongo shell with public config flags and user details :

    mongo --username <user> --password <pass> --host <Host.IP.Adrs> --port 28888

|*| Creating Config File is explained here with example :

https://github.com/mongodb/mongo/blob/master/rpm/mongod.conf



回答2:

I experienced this issue today, installing the latest version of MongoDB with Homebrew and then launching the mongo shell and entering the command "show dbs". I tested this multiple times and spent some time researching it. The symptoms match an issue that was reported here: https://jira.mongodb.org/browse/SERVER-20753 where the issue was described as building WiredTiger separately from MongoDB and using an out of date version of WiredTiger.

While this is not the case for what you and I have experienced (note that Homebrew is currently installing 3.4.9 and WiredTiger 2.9.2), I guessed that it could be a similar mismatch between WiredTiger and MongoDB, so I decided to try installing a different version.

I ended up installing the latest "dev" version using this Homebrew command:

brew install mongodb --devel

This installs MongoDB 3.5.13 and WiredTiger 3.0.0 which do not have the issue. Note that 3.4.9 was released the day you reported this issue and 3.5.13 was released the next day, although 3.4.9 is still the current community edition listed here: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/