【发布时间】:2017-08-10 10:02:43
【问题描述】:
我只想在 Ubuntu 16.04 LTS 中使用 PHP7 创建 mongoDB 客户端(1.2.9)。
我刚刚从 Apache 日志中收到如下错误。
PHP 致命错误:未捕获的 MongoDB\Driver\Exception\InvalidArgumentException:无法解析 MongoDB URI:'mongodb:/192.168.0.160:27017' in /var/www/html/db.php:4\nStack trace:\ n#0 /var/www/html/db.php(4): MongoDB\Driver\Manager->__construct('mongodb:/192.16...')\n#1 {main}\n 抛出 /var/ www/html/db.php 第 4 行
【问题讨论】:
-
mongodb://192.168.0.160:27017你少了一个斜线/ -
添加“/”后出现此错误 [Thu Aug 10 15:42:20.567779 2017] [:error] [pid 26566] [client 192.168.0.203:51667] PHP 致命错误:未捕获的 MongoDB \\Driver\\Exception\\RuntimeException: 在 testDb 上未授权执行命令 { find: "testColl", filter: { age: 30 } } in /var/www/html/db.php:10\nStack trace:\ n#0 /var/www/html/db.php(10): MongoDB\\Driver\\Manager->executeQuery('testDb.testColl', Object(MongoDB\\Driver\\Query))\n#1 { main}\n 在第 10 行的 /var/www/html/db.php 中抛出
-
那是因为您没有按要求提供用户名或密码。这也是我们在这里所说的不同的问题。如果您有新问题,那么Ask a new Question
-
我收到此类型错误,[Fri Aug 11 09:30:05.985765 2017] [:error] [pid 31307] [client 192.168.0.203:57805] PHP 注意:未定义属性:MongoDB\\ Driver\\Manager::$admin in /var/www/html/mongo.php 第 8 行 [Fri Aug 11 09:30:05.985829 2017] [:error] [pid 31307] [client 192.168.0.203:57805] PHP注意:尝试在第 10 行的 /var/www/html/mongo.php 中获取非对象的属性