【发布时间】:2015-10-29 16:18:29
【问题描述】:
我在尝试使用 PHP Mongodb 驱动程序连接到 Mongodb 时遇到问题。
实际上,我有一个名为 LRS 的数据库,它有一个名为“juano”的用户,在我的设置文件中有一个密码:“12345”我确定我编写了正确的配置。 但是当我在 Laravel 中加载我的主页时,我收到了这条消息:
MongoConnectionException (71)
HELP
Failed to connect to: localhost:27017: SASL Authentication failed on database'LRS': Authentication failed.
更具体的发现这里的错误
if (isset($config['password']) && $config['password'])
{
$options['password'] = $config['password'];
}
return new MongoClient($dsn, $options);
}
这是我的配置文件
<?php
return [
'connections' => [
'mongodb' => [
'driver' => 'mongodb',
'host' => 'localhost',
'port' => 27017,
'username' => 'juano',
'password' => '12345',
'database' => 'LRS'
],
]
];
【问题讨论】:
标签: php mongodb laravel mongodb-php