When ever I try to connect to mongo db I always get this error as below.
MongoDB shell version: 2.4.3 connecting to: test Fri Apr 26 14:31:46.941 JavaScript execution f
First start mongod
service then mongo
or mongos
Mongo DB requires space to store it files. So you should create folder structure for Mongo DB before starting the Mongodb server/client.
for e.g. MongoDb/Dbfiles where Mongo DB is installed.
Then in cmd promt exe mongod.exe and mongo.exe for client and done.
I am using version 4.0.6 ( the current release) on Linux Mint. You need to install Mongodb Compass(mongodb GUI) to interact with your databases. Here is the link: https://docs.mongodb.com/compass/master/install/
I hope this solves your problem.
Please Start the MongoDB server first and try to connect.
Pre-requisite:
Create space for storing DB and tables in any directory
Example (windows): D:\mongodbdata\
Steps:
Start server
mongod --port 5000 --dbpath D:\mongodbdata\ (please mention above created path)
Connect mongodb server (Run in another terminal/console)
mongo --port 5000
Faced same issue, my understanding is(it could be wrong)
1. Make sure mongodb is up and running
2. For linux access as sudo and for windows if connecting localhost turning off firewall may help but its not necessary
3. Just type mongo, it will try to connect to localhost by default. You need to specify IP if you are connecting to a remote server. By default test db will be used.
Start mongod server first
mongod
Open another terminal window
Start mongo shell
mongo