c24b
c24b

Reputation: 5552

Show database in mongodb show it empty while I can acess and query data

While accessing the database in command line, the 'show dbs' list all the existing databases showing the one I want to access as empty.

EDIT: Neverless using the database and running db.stats() it show the correct size of data.

The output of show dbs :

db1 (empty)

db2 (empty)

db3 0.999755859375GB

db_5 (empty)

But I can access, query, count and show the data stored in db_5.

Can someone explain me why this is shown as empty? Can I export it correctly without loosing data?

EDIT: After export and then stopping and restarting mongodb: database is now shown as completly empty and I'm then unable to select count or show data.

Upvotes: 7

Views: 9666

Answers (2)

Bruno Ferreira
Bruno Ferreira

Reputation: 484

In my case I was accessing mongo without credentials. So changed my command to

mongo --username mongouser --password mongopass

Upvotes: 10

Ruben S
Ruben S

Reputation: 971

It seems like you have to update your MongoDB Shell.

There's a known issue (SERVER-15987) where listCollections returns empty when an old version of the shell is used.

When executing the mongo command, you can see the shell version in the first line.

MongoDB shell version: 3.0.4

If you have anything less than 3.0, you should update your shell.
In Debian, this can be reinstalled using apt-get install mongodb-org-shell

source

Upvotes: 4

Related Questions