1
我已经通过作曲家安装了mongodb php库,但是我遇到了一个与权限有关的问题。有没有办法看它是否正在运行(我认为它是,因为我明显有一个开放的连接),如果是这样,我将如何去启用权限这个?MongoDB连接超时 - 权限被拒绝
下面是代码:
$client = new \MongoDB\Client("mongodb://localhost:27017");
$collection = $client->test->foo;
$result = $collection->insertOne(['name' => 'foo', 'sex' => 'Male']);
$find = $collection->find(['name' => 'foo']);
foreach ($find as $entry) {
echo $entry['_id'] . ' : ' . $entry['name'] . ' : ' . $entry['sex'];
}
我得到的异常消息是:
MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers
found (`serverselectiontryonce` set):
[Failed connecting to 'localhost:27017': Permission denied]
谢谢!
如果有人需要更多信息,请让我知道。
更新
我跑了系统shell命令蒙戈,这是什么想出了:
MongoDB shell version: 2.6.11
connecting to: test
2016-06-15T06:59:58.752-0400 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-06-15T06:59:58.753-0400 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection failed at src/mongo/shell/mongo.js:146
exception: connect failed