In this particular post, I’m going to tell you the easiest way to upload data into the mongodb atlas cluster database. You must have come across a lot of other ways to upload data to mongodb atlas using your mongodb bash sheel, creating individual documents, etc.
All the other methods except mentioned in this post is complex and hard especially if you are newbie. In this method we basically use mongodb compass to upload the data from our local computer to mongoDB atlas.
What you require before getting started:
- You must have created a cluster on mongodb atlas
- Created a database on mongodb atlas
- MongoDBCompass installed on your local PC
Upload Data in MongoDB Atlas from local computer
The first thing you need to do after you have created a database on your mongodb cluster is to connect your mongodb compass application to the atlas mogodb cluster. Below are the simple steps to do that:
Connect MongoDB compass with MongoDB Atlas cluster
Below are the easy steps to connect MongoDB compass with MongoDB Atlas cluster
- Download the latest version of mongoDB compass suitable for your operating system and install it.
Click here to download the mongdb compass
- Go to connect and then click on “connect to…” or you can directly press the ctrl + N command (on windows)
- You will see something like below image
- Paste the connection string you got from mongodb atlas
- Wait for few minutes and that’s it. You are successfully connected your mongodb compass to online mongodb atlas cluster
Upload data from MongoDB compass to MongoDB Atlas cluster
After successfully connecting with the mongodb compass with the mongodb atlas cluster you will all the databases that are present in your cluster.
Just look for the desired database and click on it’s name. After that you can see all the collection that are present in that database. If your database is empty, you will have something like below.
Now click on create collection and give your collection a desiered name. Read and check the checkboxes if necessary. Now, In my case I’ve created a collection named “mydata”.
After creating the collection, you will have something like below as you don’t have any data into the newly created collection.
Now here comes the best part that is uploading data to the collection created in the database of mongodb atlas cloud cluster. Now, just click on “Import Data” or you can also click on “ADD DATA” and then “Import File” like below.
Now, you will be presented a screen like below.
Now, just click on browse and selected the desired file from your computer that you want to import into the created collection on database of mongodb atlas cloud. Currently, mongoDB support imports from two types of files that is JSON and CSV.
After selecting the file from your local computer. Select the INput file type that is either JSON or CSV. Now click on “IMPORT”.
It will take some time if the file is big. Finally, all entries of the file will be imported to mongodb collection in form of documents. Hurray!!