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

落爺英雄遲暮 提交于 2019-12-07 07:49:46

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/19553554/show-database-in-mongodb-show-it-empty-while-i-can-acess-and-query-data

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