All Collections
Atlas Frequently Asked Questions
Create Your First Atlas Database
Create Your First Atlas Database

Create a new database using mongo shell or via connection string

Joao Boesso avatar
Written by Joao Boesso
Updated over a week ago

Creating A Database Using The Mongo Shell

If you connect to your Atlas cluster using the mongo shell and the connection string from the Atlas dashboard, you will automatically be connected to a database called test .   If you immediately execute db.colors.insert({name:'red'})  then you will have just created a collection called colors  in the database called test .

Don't want to use the test database?  No problem - you can create a new database with the use  command, like so:

use food
db.vegetables.insert({name: 'broccoli'})

.... will create a new database called food. The insert  command shown will create a collection called vegetables.

Creating A Database From Your Application

If you click on the Connect button from the Clusters dashboard and select the URI Connection String, you'll see something like this:

mongodb://exampleuser:<PASSWORD>@server1:27017,server2:27017,server3:27017/<DATABASE>?ssl=true&replicaSet=example-shard-0&authSource=admin

New users sometimes wonder, "What name am I supposed to put in the <DATABASE> field?" or "How do I create the database that I will put in this string?".  The answer is:  just put any name you prefer - if the database does not yet exist, MongoDB will automatically create it.

Did this answer your question?