注意红色那行的代码,一定要加上这一句!!!
‘mongodb_default‘ => [
‘driver‘ => ‘mongodb‘,
‘host‘ => env(‘MONGODB_DEFAULT_HOST‘, ‘localhost‘),
‘port‘ => env(‘MONGODB_DEFAULT_PORT‘, 27017),
‘database‘ => env(‘MONGODB_DEFAULT_DATABASE‘),
‘username‘ => env(‘MONGODB_DEFAULT_USERNAME‘),
‘password‘ => env(‘MONGODB_DEFAULT_PASSWORD‘),
‘timezone‘ => env(‘DB_TIMEZONE‘, ‘+08:00‘),
‘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(‘MONGODB_DEFAULT_DATABASE‘), // required with Mongo 3+
],
],
解决jenssegers/mongodb无法连接带密码的mongodb数据库问题