Mongodb SASL鉴权失败


SASL Authentication failed on Mongodb database

我有一个问题,试图连接到Mongodb使用PHP Mongodb驱动程序。

实际上我有一个名为LRS的数据库,它在我的设置文件中有一个名为"juano"的用户,其pwd:"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'
      ],
  ]
];

对不起,伙计们,我觉得很愚蠢,因为问题是我在本地机器上启动mongod,然后我在虚拟机上运行我的web。所以,在我的数据库连接配置文件中,我在服务器字段中写了"localhost"。

请检查

.env

文件在laravela

在这里添加所有数据库配置细节并检查它&添加后如有问题请告诉我。

APP_ENV=local
APP_DEBUG=true
APP_KEY= your key already given
DB_HOST=localhost
DB_DATABASE= your database here
DB_USERNAME= your username here
DB_PASSWORD= your password here
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

谢谢,关于