...

/

Creating Databases and Collections

Creating Databases and Collections

Create new databases and collections in MongoDB using the shell.

A database in MongoDB is a container for collections, and a collection contains a group of documents. Before we can store data, we first need to create these structures.

Creating a database and collection

We don't need a special command to create a database in MongoDB. Simply, switch to a new database name using the use command as follows:

Press + to interact
use myNewDatabase

Remember that MongoDB has not created ...