To create a collection in MongoDB, you can use the `db.createCollection(name, options)` method. Here’s how to do it.
First, you’ll need to connect to MongoDB using the mongo shell or a MongoDB client.
In the mongo shell, you can use the following commands:
```
mongo
```
This will connect you to MongoDB on localhost and the default port (27017).
Once you’re connected, you can select your database. Assume we have a database called `mydatabase`:
```
use mydatabase
```
Now issue the command to create a new collection. Assume you want to create a collection named `mycollection`:
```
db.createCollection(“mycollection”)
```
This will create a new collection named `mycollection` in the `mydatabase` database.
You can optionally provide some options in the `db.createCollection(name, options)` method like the maximum size or the maximum number of documents and other options.
For example:
```
db.createCollection(“mycollection”, { capped : true, size : 5242880, max : 5000 } )
```
This will create a capped collection, meaning it has a maximum size of 5242880 bytes and can only hold 5000 documents.
Remember, MongoDB creates collections automatically when you insert some document. You do not need to create collection before you insert documents, it will be created automatically when you insert some documents. This is the case in most scenarios. The `createCollection` method is mainly used when you want to provide some options for the collection.