我使用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
但仍然无法连接到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
有人可以告诉我如何解决它吗?或者如何正确安装mongodb? 感谢
答案 0 :(得分:1)
当您输入mongod命令时,您是否也给它一个路径?这通常是个问题。您不必费心使用conf文件。只需输入
即可mongod --dbpath =“把你的路径放到你希望它保存数据库工作区的地方!!没有这些愚蠢的引号我也可以添加!”
示例:mongod --dbpath = C:/ Users / Kyle-3 / Desktop / DEV / dangerzonearea / test / mongodb
这是我的路径,不要忘记,如果你从它上面复制它,在窗户上向前翻转斜线,否则它将不起作用!