若使用的mongodb数据库不是admin权限(即添加的用户)时, 会连接失败, 权限不足, 需更改tp5拓展文件
文件位置:
\vendor\topthink\think-mongo\src\Connection.php 152行
在这段代码的最后加上 ."/".$this->dbName;
//更改前
$host = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
//更改后
$host = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '')."/".$this->dbName;