這里詳細(xì)描述問(wèn)題
使用擴(kuò)展為"jenssegers/mongodb": "3.8.0",線(xiàn)上的mongodb版本("version": "7.0.8")
現(xiàn)在使用navicat連接線(xiàn)上的mongodb地址是可以連接成功的,
但是代碼在database里面配置在下面(host本應(yīng)該是連接的線(xiàn)上地址,但是為了規(guī)避所以先寫(xiě)成了本地的),
然后在新增數(shù)據(jù)的時(shí)候一致報(bào)錯(cuò)( Authentication failed),嘗試在配置中options中的參數(shù),但是也是沒(méi)有效果,請(qǐng)教一個(gè)各位大佬,要怎么去解決這個(gè)問(wèn)題
// 基礎(chǔ)配置信息如下
'mongodb' => [
'driver' => 'mongodb',
'host' => '127.0.0.1',
'port' => 27017,
'database' => 'bbs',
'username' => 'bbs',
'password' => 'e8fSktkKzX3cFKBt',
'options' => [
// 'authSource' => 'bbs',
// 'ssl' => false,
'appname' => 'homestead'
],
],
// 操作代碼
public function __construct()
{
$this->mongoSql = Db::connection('mongodb')->collection('requestip_list');
}
/**
* 新增請(qǐng)求ip記錄信息
*
* @param array $arr 數(shù)據(jù)信息
* @return void
*/
public function siginMongoInfo(array $arr)
{
$arr['update_time'] = Carbon::now()->format('Y-m-d H:i:s');
$arr['create_time'] = Carbon::now()->format('Y-m-d H:i:s');
// Db::connection('mongodb')->collection('requestip_list')->insert($arr);
$this->mongoSql->insert($arr);
}
MongoDB\Driver\Exception\AuthenticationException: Authentication failed. in D:\phpstudy_pro\WWW\bbs-api\vendor\mongodb\mongodb\src\Operation\InsertMany.php:163<br />
Stack trace:<br />
#0 D:\phpstudy_pro\WWW\bbs-api\vendor\mongodb\mongodb\src\Operation\InsertMany.php(163): MongoDB\Driver\Server->executeBulkWrite()<br />
#1 D:\phpstudy_pro\WWW\bbs-api\vendor\mongodb\mongodb\src\Collection.php(908): MongoDB\Operation\InsertMany->execute()<br />
#2 [internal function]: MongoDB\Collection->insertMany()<br />
#3 D:\phpstudy_pro\WWW\bbs-api\vendor\jenssegers\mongodb\src\Jenssegers\Mongodb\Collection.php(42): call_user_func_array()<br />
#4 D:\phpstudy_pro\WWW\bbs-api\vendor\jenssegers\mongodb\src\Jenssegers\Mongodb\Query\Builder.php(570): Jenssegers\Mongodb\Collection->__call()<br />
#5 D:\phpstudy_pro\WWW\bbs-api\app\service\RequestipListService.php(39): Jenssegers\Mongodb\Query\Builder->insert()<br />