[MongoDB\Driver\ExceptionAuthenticationException]
Authentication failed.
i actually replaced the database in options array to db
mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'db' => 'admin' // replace "database" to "db"
]
],
Upgrade mongo driver dependence mongodb/mongodb 1.0.3 to 1.0.4 and update database.php
```php
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'database' => env('DB_DATABASE') // sets the authentication database required by mongo 3
]
],
It works...thanks a lot @uriel2707
i want to connect to remote server from my local machine but i am having Authentication failed error .
i am able to connect to my local machine correctly but i cant connect to the remote server
from my local machine i can connect to the remote host via ssh and specify the user and the pwd .
any idea on how to connect to a remote sever please thanks in advance
'mongodb2' => [
'driver' => 'mongodb',
'host' => env('DB2_HOST', 'xx.xxx.xx.xx'),
'port' => env('DB2_PORT', 27017),
'database' => env('DB2_DATABASE','admin'),
'username' => env('DB2_USERNAME',''),
'password' => env('DB2_PASSWORD',''),
'use_mongo_id' => false,
'options' => [
'database' => 'admin',
]
]
@ssallah why are you using mongodb2 as the key? also use_mongo_id is not necessary
'options' => [
'authSource' => 'admin',
]
use admin
db.createUser({user: "admin", pwd: "123456", roles:["root"]})
This error is exist .. I am able to connect through client but but not able to connect laravel mongodb driver .. authentication error is coming
Most helpful comment
Its works
Upgrade mongo driver dependence mongodb/mongodb 1.0.3 to 1.0.4 and update
database.php```php
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
'database' => env('DB_DATABASE') // sets the authentication database required by mongo 3
]
],