Skip to content

Authentication failed. (MongoDB 3.2 and Laravel 5.3) #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kheengz opened this issue Sep 20, 2016 · 8 comments
Closed

Authentication failed. (MongoDB 3.2 and Laravel 5.3) #963

kheengz opened this issue Sep 20, 2016 · 8 comments

Comments

@kheengz
Copy link

kheengz commented Sep 20, 2016

[MongoDB\Driver\Exception\AuthenticationException]
Authentication failed.

@kheengz
Copy link
Author

kheengz commented Sep 23, 2016

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"
]
],

@kheengz kheengz closed this as completed Sep 23, 2016
@uriel2707
Copy link

Its works

Upgrade mongo driver dependence mongodb/mongodb 1.0.3 to 1.0.4 and update database.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
    ]
],

@kheengz
Copy link
Author

kheengz commented Dec 29, 2016

It works...thanks a lot @uriel2707

@ssallah
Copy link

ssallah commented May 22, 2017

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',
]
]

@kheengz
Copy link
Author

kheengz commented May 23, 2017

@ssallah why are you using mongodb2 as the key? also use_mongo_id is not necessary

@derogithub
Copy link

'options' => [
'authSource' => 'admin',
]

@mohamedhafezqo
Copy link

use admin
db.createUser({user: "admin", pwd: "123456", roles:["root"]})

@nkumarjain
Copy link

This error is exist .. I am able to connect through client but but not able to connect laravel mongodb driver .. authentication error is coming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants