MongoDB - Database Operations
By default MongoDB comes with 3 pre-installed databases: admin, config, and local. These databases are described below:
- admin: Used to store system collections, user authentication and role information. Access limited to administrators of MongoDB.
- config: Used to store internal information of the shard and cluster.
- local: Used to store local information about the replication process and other related data.
Viewing Databases
To view all databases:
Current Database
To view the currently selected (used) database:
Selecting Database
To select (and use) a database, the command use can be used:
Info
Note that now when running the command show dbs to list the databases, our database is not yet visible. It will be visible after we create our first collection into it.
Removing (Dropping) Database
To remove (drop) a database, you need to switch into the database and the command db.dropDatabase() can be used.
Example below: