I'm trying to get MongoDB installed and running on my new Windows 8 computer. However, I cannot seem to be able to connect to MongoDB when using the mongo.exe shell.
I got the following error:
MongoDB shell version: 2.4.8
connecting to: test
Sun Dec 15 14:06:39.835 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:146
exception: connect failed
How can I connect to MongoDB properly? I already have MongoDB installed, along with having the Data Directory all set up. I also created a specific directory for the MongoDB log files, and installed the MongoDB service.
Best Answer
In the directory that you ran
mongo.exe
you should also see the executablemongod.exe
.mongo.exe
is the shell that connects to the server/daemon that allows you to issue commands and query your databases.mongod.exe
is the actaulmongo
server/daemon.First run
mongod.exe
to start the server then in a new command window runmongo.exe
. The shell should now connect to the running server. For production you will want to look at settingmongod
as Windows Service instead of just running in a separate command window.