Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb show dbs listDatabases failed

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
like image 503
Sujay U N Avatar asked Nov 16 '25 20:11

Sujay U N


1 Answers

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

like image 198
Sujay U N Avatar answered Nov 18 '25 14:11

Sujay U N



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!