I Installed mongoDB in my laravel 8 project for first time, to explore mongoDB functionalities When I run php artisan migrate I got: MongoDB\Driver\Exception\AuthenticationException Authentication failed. at D:\xampp\htdocs\Mongo\mongonews\vendor\mongodb\mongodb\src\Command\ListCollections.php:115 my : D:\xampp\htdocs\Mongo\mongonews\config\database.php I set the following:
'mongodb' => [
'driver' => 'mongodb',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'options' => [
// here you can pass more settings to the Mongo Driver Manager
// see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use
'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
],
],
And this is my .env: DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=mongonews
DB_USERNAME=root
DB_PASSWORD=
Thanks Geaks, appreciate your help to start my first time mongo db based laravel app All the best.
[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)) |