I'm installing Mongodb in several time in Ubuntu 15.04 but it not install properly and mongo shell has an error :
mongo
MongoDB shell version: 3.0.1
connecting to: test
2015-04-07T18:46:14.958+0430 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-04-07T18:46:14.959+0430 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
I'm installing the 2.6.4 and updated to 3.0.1 but the error not resolve. I found this Answer in stackoverflow and search to find mongod.lock in ubuntu and remove it and then flow this step :
Step 2: Repair mongodb.
sudo mongod --repair
Step 3: start mongodb.
sudo start mongodb
or
sudo service mongodb start
Step 4: Check status of mongodb.
sudo status mongodb
or
sudo service mongodb status
Step 5: Start mongo console.
mongo
for reapir :
mongod --repair
2015-04-07T18:58:15.595+0430 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2015-04-07T18:58:15.595+0430 I CONTROL [initandlisten] dbexit: rc: 100
This error for sudo service mongodb start :
sudo service mongodb start
[sudo] password for amir:
Failed to start mongodb.service: Unit mongodb.service failed to load: No such file or directory.
and for status :
sudo service mongodb status
● mongodb.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
and for start shell the first problem has throw.
I try install mongodb with linuxbrew and again the error did not gone...
--------------- update -------- since in what say "demostene" :
I think you just need to create this folder /data/db . Try sudo mkdir /data/db then repair
I have the /data/db
in the home/amir/data/db
then i create the /data/db
in root and nothing change...
In last time i installing the mongo with linuxbrew and for that the sudo command did not work in sudo mongod --repair
and other step and without sudo that's command did not work...
so i first try sudo su
in terminal and try the step in root
in first step say the mongodb is not install and for install it insert : apt-get install mongo-server
I insert this command and install mongodb again.
Now in root mongo shell start correctly in this version :
root@AbrFa:/home/amir# mongo
MongoDB shell version: 2.6.3
connecting to: test
>
and without the sudo su mongo shell start in this version :
MongoDB shell version: 3.0.1
connecting to: test
By the way I want's to know do not conflict this 2 version with each other?