1

I've connected to mLab using MongoClient.connect, but now I want to create a local database rather than use mLab. I've tried changing the URL to "mongodb://localhost:27017/mydb" to create a database locally as suggested, but I'm getting a failed to connect to server error. Is there anything I should install? Or am I just missing something?

1
  • 1
    Yes. You are missing actually installing a server. The nodejs driver does not install the mongodb server. It's just a driver for connecting. Commented Jul 5, 2017 at 12:12

2 Answers 2

1

First, install your mongoDB server: https://docs.mongodb.com/manual/installation/

After that, you should be able to start your local mongodb server:

sudo service mongod start //in case of linux

Here the docs to start the mongodb server

Then, you will type mongo and the client command line will start. And when typing use yourDatabase, mongo will create the database if it does not exist.

Then, your server will be up, and the database created. Anyway, check the docs if you need the guides for windows or other systems.

Sign up to request clarification or add additional context in comments.

Comments

0

First you need to understand how server works and mlab works. mLab is a company who provide database as a services. Means you no need to handle server hurdles, they take care server , backups , infrastructure etc. They provide mongodb server , You just need to create database on mongodb server's and use them.

Now comes to main points.

If you want use mongodb on your local system then you first need to install mongodb on your local system and then connect it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.