Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SASL Authentication failed on Mongodb database

I-m having an issue trying connect to Mongodb using PHP Mongodb driver.

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);
}

And this is my config file

 <?php
   return [
     'connections' => [
       'mongodb' => [
         'driver'   => 'mongodb',
         'host'     => 'localhost',
         'port'     => 27017,
         'username' => 'juano',
         'password' => '12345',
         'database' => 'LRS'
      ],
  ]
];
like image 920
juanObrach Avatar asked Nov 23 '25 18:11

juanObrach


1 Answers

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.

like image 182
juanObrach Avatar answered Nov 26 '25 14:11

juanObrach



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!