This is the error I get whenever I try to run mongo
MongoDB shell version: 2.2.2
connecting to: test
Wed Dec 12 15:51:57 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed
Whenever I run mongod on shell I get this:
Wed Dec 12 15:53:04 [initandlisten] MongoDB starting : pid=763 port=27017 dbpath=/data/db/ 64-bit host=rachitpuri.one97.delhi.net
Wed Dec 12 15:53:04 [initandlisten]
Wed Dec 12 15:53:04 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Wed Dec 12 15:53:04 [initandlisten] db version v2.2.2, pdfile version 4.5
Wed Dec 12 15:53:04 [initandlisten] git version: nogitversion
Wed Dec 12 15:53:04 [initandlisten] build info: Darwin tensix-slave.macports.org 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Wed Dec 12 15:53:04 [initandlisten] options: {}
Wed Dec 12 15:53:04 [initandlisten] journal dir=/data/db/journal
Wed Dec 12 15:53:04 [initandlisten] recover : no journal files present, no recovery needed
Wed Dec 12 15:53:04 [websvr] admin web console waiting for connections on port 28017
Wed Dec 12 15:53:04 [initandlisten] waiting for connections on port 27017
Some how I have to mongod.conf files is that a conflict in system at different locations and in none of them dbpath=/data/db
There is two parts of mongoDB that are interacting here. The first part is mongod
which is the server process itself. The second part is mongo
which is the shell.
The shell will connect to the server process, and then allow you to issue the commands, run queries and all other operations normally associated with running MongoDB. Because of this you will need both mongod
and mongo
running at the same time.
You can do this several ways. The easiest is to open a terminal window (or a command prompt under Windows) and start the mongod
process. Then in another terminal window, start the mongo
process. If all of the defaults are being used this will result in the mongo
process connecting to the mongod
process and allowing you to interact with MongoDB.
The end of the log from mongod
that you have shown indicates that it is ready to accept connections:
Wed Dec 12 15:53:04 [initandlisten] waiting for connections on port 27017
This means you can start a mongo
process in another terminal window and connect to the server on port 27017. The mongod
process will still need to be running, otherwise the mongo
process will have nothing to connect to.
There is more information on starting mongod
in the installation guides for your operating system.
You can find more information on using the shell here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With