1

I use sudo mongod --repair

win@win-VirtualBox:/var/lib/mongodb$sudo mongod --repair
2014-09-02T22:57:35.759+0800 [initandlisten] MongoDB starting : pid=28790 port=27017     dbpath=/data/db 64-bit host=winsome-VirtualBox
2014-09-02T22:57:35.760+0800 [initandlisten] db version v2.6.4
2014-09-02T22:57:35.761+0800 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-02T22:57:35.761+0800 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-09-02T22:57:35.762+0800 [initandlisten] allocator: tcmalloc
2014-09-02T22:57:35.762+0800 [initandlisten] options: { repair: true }
2014-09-02T22:57:35.776+0800 [initandlisten] finished checking dbs
2014-09-02T22:57:35.776+0800 [initandlisten] dbexit: 
2014-09-02T22:57:35.777+0800 [initandlisten] shutdown: going to close listening sockets...
2014-09-02T22:57:35.777+0800 [initandlisten] shutdown: going to flush diaglog...
2014-09-02T22:57:35.778+0800 [initandlisten] shutdown: going to close sockets...
2014-09-02T22:57:35.778+0800 [initandlisten] shutdown: waiting for fs preallocator...
2014-09-02T22:57:35.779+0800 [initandlisten] shutdown: closing all files...
2014-09-02T22:57:35.779+0800 [initandlisten] closeAllFiles() finished
2014-09-02T22:57:35.780+0800 [initandlisten] shutdown: removing fs lock...
2014-09-02T22:57:35.780+0800 [initandlisten] dbexit: really exiting now
win@win-VirtualBox:/var/lib/mongodb$ sudo service mongod start
mongod start/running, process 28806

But still can't connect to mongodb

win@win-VirtualBox:/var/lib/mongodb$ mongo 
MongoDB shell version: 2.6.4
connecting to: test
2014-09-02T22:58:07.395+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111    Connection refused
2014-09-02T22:58:07.396+0800 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1),   connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

Can someone tell me how to fix it ? or how to install mongodb correctly? Thanks

user2492364
  • 6,543
  • 22
  • 77
  • 147

1 Answers1

1

When you typed in the mongod command, did you also give it a path? This is usually the issue. You don't have to bother with the conf file. simply type

mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"

example: mongod --dbpath=C:/Users/Kyle-3/Desktop/DEV/dangerzonearea/test/mongodb

That is my path and don't forget if on windows to flip the slashes forward if you copied it from the or it won't work!

Urasquirrel
  • 1,461
  • 1
  • 18
  • 34