How To Create DB In MongoDB?

Open MongoDB shell or MongoDB Compass

Connect to your MongoDB server

Use the database name with the `use` command

Example: `use myDatabase`

Create a collection or insert a document

Example: `db.myCollection.insertOne({ name: “test” })`

Verify the database exists with `show dbs`

In MongoDB, the database is created automatically when data is first added

Suggested for You

Trending Today