0

I have a mongodb running on server:27017.

From a different machine, I installed mongo-client and connected to mongodb running on server.

I have three dbs in mongo: admin, local, and template (these were created for me by a script).

When I do:

use template
db.stats()

I get:

db.stats()
{
        "db" : "template",
        "collections" : 2,
        "views" : 0,
        "objects" : 1001,
        "avgObjSize" : 565.1118881118881,
        "dataSize" : 565677,
        "storageSize" : 110592,
        "numExtents" : 0,
        "indexes" : 5,
        "indexSize" : 86016,
}

If, however, I do

show collections

or

db.getCollectionNames()

I get nothing.

What does this mean? Why is there a DB with indexes and objects, but no collections, and why does the count of collections in template db >0, but show collections gives nothing back?

RebeccaK375
  • 871
  • 3
  • 17
  • 28
  • What is the output of `version()` and `db.version()` in your `mongo` shell? One likely cause would be running a very old (pre-3.0) shell with MongoDB 3.0+ (which added a storage engine API). – Stennie Oct 05 '18 at 22:29
  • Ah! Yes, you are right. They are different and the shell is pre-3.0. Is there a way to update the shell only? Instructions I see are usually for updating MongoDB, but not the shell. – RebeccaK375 Oct 12 '18 at 12:29
  • The `mongo` shell is included when you install MongoDB server. There is a separate package for Linux, but for Windows and macOS you'd generally just run from the `bin` directory after installing. What O/S and version are you using? Also, what version of MongoDB server are you using? The major version of the `mongo` shell (eg. 3.6.x) should match the major version of your MongoDB server. – Stennie Oct 14 '18 at 20:29

0 Answers0