How to list all databases in the mongo shell? How to list all databases in the mongo shell? database database

How to list all databases in the mongo shell?


Listing all the databases in mongoDB console is using the command show dbs.

For more information on this, refer the Mongo Shell Command Helpers that can be used in the mongo shell.


For database list:

show databasesshow dbs

For table/collection list:

show collectionsshow tablesdb.getCollectionNames()


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

db.adminCommand('listDatabases')

or alternatively:

db.getMongo().getDBNames()