How to list all databases in the mongo shell?

前端 未结 7 1787
灰色年华
灰色年华 2021-01-29 19:23

I know how to list all collections in a particular database, but how do I list all available databases in MongoDB shell?

7条回答
  •  Happy的楠姐
    2021-01-29 20:07

    For MongoDB shell version 3.0.5 insert the following command in the shell:

    db.adminCommand('listDatabases')
    

    or alternatively:

    db.getMongo().getDBNames()
    

提交回复
热议问题