How do I view databases in MongoDB?
Category:
technology and computing
data storage and warehousing
If you want to check your databases list, use the command show dbs. Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it. In MongoDB default database is test.
Considering this, how do I open MongoDB in terminal?
The MongoDB Shell is located in the same place as the other binaries. So to run it, open a new Terminal/Command Prompt window and enter mongo (Linux/Mac) or mongo.exe (Windows). This assumes that the path has been added to your PATH. If it hasn't, you'll need to provide the full path.
Also question is, how do I show all databases in MongoDB?
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. show databases //Print a list of all available databases. show dbs // Print a list of all databases on the server.
Working with the mongo Shell
- To display the database you are using, type db :
- The operation should return test , which is the default database.
- To switch databases, issue the use <db> helper, as in the following example:
- See also db.
- To list the databases available to the user, use the helper show dbs . [