while trying this mongo command in ubuntu I am getting this error.
ritzysystem@ritzysystem-Satellite-L55-A:~$ mongo
MongoDB shell version: 2.6.1
I just removed mongo following the instructions here: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ And then I installed again following the instructions in the given link. Everything worked smoothly!
I had the same problem on my Mac, and I installed mongodb via homebrew. I solve this problem by the homebrew services command.
$ brew services start mongodb
$ mongo
$ brew services stop mongodb
I faced the same problem, so please check is there mongodb folder, firstly try to remove that folder
rm -rf /var/lib/mongodb/*
Now try to start mongo and if same problem then its mongodb lock file which prevent to start mongo, so please delete the mongo lock file
rm /var/lib/mongodb/mongod.lock
For forcefully rm -rf /var/lib/mongodb/mongod.lock
service mongodb restart if already in sudo mode
otherwise you need to use like sudo service mongod start
or you can start the server using fork method
mongod --fork --config /etc/mongod.conf
and for watching the same is it forked please check using the below command
ps aux | grep mongo
Mongo 3.*.* - OSX - 2017
From README
RUNNING
Change directory to mongodb-osx-x86_64-3.*.*/bin
To run a single server database:
$ mkdir /data/db
$ ./mongod
Go to new Terminal
$ # The mongo javascript shell connects to localhost and test database
$ # by default -Run the following command in new terminal
$ ./mongo
> help
Run the following command :
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
Connection refused to MongoDB errno 111
MacOS:
rm /usr/local/var/mongodb/mongod.lock
sudo service mongod restart
Make sure you have run the MongoDB's Service before you want to connect the console.
run and start the server:
$ sudo mongod
then:
$ mongo
...
>