-
Notifications
You must be signed in to change notification settings - Fork 1.4k
why project connected the mongo Authentication failed?but client connected succ... #1028
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
Comments
Same problem after upgrading this package from v3.1.1 to v3.1.3 using Any use of Moloquent throw a I did not changed anything in my Stack: |
Same error here. I solved with franquis comment: #1028 (comment) Change composer.json |
other solved: add the 'mongodb' => [ |
I worked that way '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 ] ], |
Its worksUpgrade mongo driver dependence mongodb/mongodb 1.0.3 to 1.0.4 and update '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
]
], |
update 'mongodb' => [
'driver' => 'mongodb',
'host' => [env('MONGODB_SERVER01'), env('MONGODB_SERVER02'), env('MONGODB_SERVER03')],
'database' => env('MONGODB_DATABASE'),
'username' => env('MONGODB_USERNAME'),
'password' => env('MONGODB_PASSWORD'),
'options' => [
'database' => env('MONGODB_DATABASE'),//不加导致auth fail
'replicaSet' => env('MONGODB_REPLICASET')//'yunpanrs'
]
], because in 'jenssegers\mongodb\src\Jenssegers\Mongodb\Connection.php' line 176 protected function getDsn(array $config)
{
// Check if the user passed a complete dsn to the configuration.
if (!empty($config['dsn'])) {
return $config['dsn'];
}
// Treat host option as array of hosts
$hosts = is_array($config['host']) ? $config['host'] : [$config['host']];
foreach ($hosts as &$host) {
// Check if we need to add a port to the host
if (strpos($host, ':') === false && !empty($config['port'])) {
$host = $host . ':' . $config['port'];
}
}
// Check if we want to authenticate against a specific database.
$auth_database = isset($config['options']) && !empty($config['options']['database']) ? $config['options']['database'] : null;
return 'mongodb://' . implode(',', $hosts) . ($auth_database ? '/' . $auth_database : '');
} |
@lokitold uriel2707 it should be added to the docs. Instead of |
I have still facing same issue.. stack: database.php: log: |
I have solved my issue myself... cheers solution: |
That can be fixed by quoting values that need to use that symbol |
[2016-11-07 11:59:41] local.ERROR: MongoDB\Driver\Exception\AuthenticationException: Authentication failed. in /data/www/cloudclass-api/vendor/mongodb/mongodb/src/Operation/Find.php:180
Stack trace:
#0 /data/www/cloudclass-api/vendor/mongodb/mongodb/src/Operation/Find.php(180): MongoDB\Driver\Server->executeQuery('cloudclass-test...', Object(MongoDB\Driver\Query), Object(MongoDB\Driver\ReadPreference))
#1 /data/www/cloudclass-api/vendor/mongodb/mongodb/src/Collection.php(437): MongoDB\Operation\Find->execute(Object(MongoDB\Driver\Server))
#2 [internal function]: MongoDB\Collection->find(Array, Array)
#3 /data/www/cloudclass-api/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Collection.php(42): call_user_func_array(Array, Array)
#4 /data/www/cloudclass-api/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Query/Builder.php(370): Jenssegers\Mongodb\Collection->__call('find', Array)
#5 /data/www/cloudclass-api/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Query/Builder.php(182): Jenssegers\Mongodb\Query\Builder->getFresh(Array)
#6 /data/www/cloudclass-api/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1577): Jenssegers\Mongodb\Query\Builder->get(Array)
#7 /data/www/cloudclass-api/app/Http/Controllers/LessonController.php(743): Illuminate\Database\Query\Builder->first()
#8 [internal function]: App\Http\Controllers\LessonController->show()
#9 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9424): call_user_func_array(Array, Array)
#10 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9486): Illuminate\Routing\Controller->callAction('show', Array)
#11 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9466): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\LessonController), Object(Illuminate\Routing\Route), 'show')
#12 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#13 /data/www/cloudclass-api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#14 /data/www/cloudclass-api/vendor/tymon/jwt-auth/src/Middleware/GetUserFromToken.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#15 [internal function]: Tymon\JWTAuth\Middleware\GetUserFromToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, Array)
#17 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#18 /data/www/cloudclass-api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#20 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9948): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#21 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9467): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 /data/www/cloudclass-api/bootstrap/cache/compiled.php(9454): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\LessonController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'show')
#23 /data/www/cloudclass-api/bootstrap/cache/compiled.php(8524): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'show')
#24 /data/www/cloudclass-api/bootstrap/cache/compiled.php(8511): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#25 /data/www/cloudclass-api/bootstrap/cache/compiled.php(8225): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
The text was updated successfully, but these errors were encountered: