mongodb异常,无法连接
发布于 1天前 作者 qianjiahao 110 次浏览 来自 问答

今天刚刚开机,启动服务后发现数据库无法访问27017端口,于是就尝试 ./mongo 发现抛出异常:

qianjiahaodeMacBook-Pro:bin qianjiahao$ ./mongo MongoDB shell version: 3.0.0 connecting to: test 2015-03-15T10:38:16.504+0800 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused 2015-03-15T10:38:16.505+0800 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

于是又尝试 ./mongod 发现提示中有这一句:

2015-03-15T10:49:24.602+0800 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

我就按网上说的 删除了/data/db/mongod.lock文件,但是发现还是没有效果,输入./mongod依然提示 上面写道的错误。

2015-03-15T10:49:24.602+0800 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

后来我天真的删除了mongdb的文件和data/db里的文件,在重新下载后,配置了data/db ,结果发现错误依然存在,小弟新人,希望大家帮帮忙,望解决,谢谢

4 回复

试一下

sudo mongod

@leapon

qianjiahaodeMacBook-Pro:~ qianjiahao$ cd mongodb/ qianjiahaodeMacBook-Pro:mongodb qianjiahao$ ls GNU-AGPL-3.0 THIRD-PARTY-NOTICES README bin qianjiahaodeMacBook-Pro:mongodb qianjiahao$ cd bin qianjiahaodeMacBook-Pro:bin qianjiahao$ ls bsondump mongodump mongoimport mongorestore mongostat mongo mongoexport mongooplog mongos mongotop mongod mongofiles mongoperf mongosniff qianjiahaodeMacBook-Pro:bin qianjiahao$ sudo mongod Password: sudo: mongod: command not found qianjiahaodeMacBook-Pro:bin qianjiahao$

在进入bin后 提示命令无法找到

sudo ./mongod

@leapon 恩 问题解决了,谢谢啦

回到顶部