docker上で、php+laravelコンテナと、mongodbコンテナをセットしてシステム構築した際に出たエラー
■エラー内容
[2020-06-14 11:53:47] local.ERROR: command listCollections requires authentication {"exception":"[object]
(MongoDB¥¥Driver¥¥Exception¥¥CommandException(code: 13): command listCollections requires authentication at ./vendor/mongodb/mongodb/src/Operation/ListCollections.php:132)
[stacktrace]
#0 ./vendor/mongodb/mongodb/src/Operation/ListCollections.php(132): MongoDB¥¥Driver¥¥Server->executeCommand('kabudb', Object(MongoDB¥¥Driver¥¥Command), Array)
#1 ./vendor/mongodb/mongodb/src/Operation/ListCollections.php(89): MongoDB¥¥Operation¥¥ListCollections->executeCommand(Object(MongoDB¥¥Driver¥¥Server))
#2 ./vendor/mongodb/mongodb/src/Database.php(343): MongoDB¥¥Operation¥¥ListCollections->execute(Object(MongoDB¥¥Driver¥¥Server))
#3 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(44): MongoDB¥¥Database->listCollections()
#4 ./vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Schema/Builder.php(58): Jenssegers¥¥Mongodb¥¥Schema¥¥Builder->hasCollection('data_types')
#5 ./vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(223): Jenssegers¥¥Mongodb¥¥Schema¥¥Builder->hasTable('data_types')
#6 ./vendor/tcg/voyager/src/VoyagerServiceProvider.php(260): Illuminate¥¥Support¥¥Facades¥¥Facade::__callStatic('hasTable', Array)
#7 ./vendor/tcg/voyager/src/VoyagerServiceProvider.php(107): TCG¥¥Voyager¥¥VoyagerServiceProvider->registerGates()
#8 [internal function]: TCG¥¥Voyager¥¥VoyagerServiceProvider->boot(Object(Illuminate¥¥Routing¥¥Router), Object(Illuminate¥¥Events¥¥Dispatcher))
#9 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#10 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate¥¥Container¥¥BoundMethod::Illuminate¥¥Container¥¥{closure}()
#11 ./vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate¥¥Container¥¥BoundMethod::callBoundMethod(Object(Illuminate¥¥Foundation¥¥Ap
■エラー原因
.env のパラメータと、config/database.phpのパラメータが結びついてなかった
コメントアウトになってたのできちんと設定
■対応内容
.env
DB_USERNAME=hoge
DB_PASSWORD=hoge
config/database.php
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),