【发布时间】:2016-07-18 12:28:17
【问题描述】:
我正在使用这种方法连接到远程数据库: (SSH隧道在后台运行)
$mongo = new Mongo('mongodb://[root:password]@localhost:27018');
但是我得到这样的错误:
致命错误:未捕获的异常“MongoConnectionException”与 消息'无法连接到:localhost:27018:SASL 身份验证 数据库“管理员”失败:身份验证失败。在 /var/www/html/mongo_seed/index.php:22 堆栈跟踪:#0 /var/www/html/mongo_seed/index.php(22): Mongo->__construct('mongodb://[root...') #1 {main} 抛出 /var/www/html/mongo_seed/index.php 第 22 行
如何在参数字符串中定义要连接的数据库?否则我该如何一个接一个地完成整个事情?
【问题讨论】: