Mongodb数据库上的SASL身份验证失败 [英] SASL Authentication failed on Mongodb database
问题描述
我在尝试使用PHP Mongodb驱动程序连接到Mongodb时遇到问题.
I-m having an issue trying connect to Mongodb using PHP Mongodb driver.
实际上,我有一个名为LRS的数据库,并且我的设置文件中有一个名为"juano"的用户,其密码为pwd:"12345",我确定我编写了正确的配置. 但是,当我在Laravel中加载主页时,会收到以下消息:
Actually I have a database called LRS and it has a user called "juano" with a pwd:"12345" in my settings file I-m sure that I wrote the correct configuration. But when I load my homepage in Laravel I receive this message:
MongoConnectionException (71)
HELP
Failed to connect to: localhost:27017: SASL Authentication failed on database'LRS': Authentication failed.
更具体的错误在这里找到
More specific the error found here
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'
],
]
];
推荐答案
对不起,我感到很愚蠢,因为问题是我在本地计算机上启动mongod,然后将我的网站运行到虚拟机中. 因此,在我的数据库连接配置文件中,我在服务器字段中写了"localhost".
Sorry guys, I-m feel stupid because the problem was I started mongod in my local machine and then I ran my web into a Virtual Machine. So, in my database connection config file I wrote "localhost" in the server field.
这篇关于Mongodb数据库上的SASL身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!