think-orm icon indicating copy to clipboard operation
think-orm copied to clipboard

MongoDB如果加上用户认证的话不带数据库名字无法认证

Open kebenxiaoming opened this issue 3 years ago • 1 comments

if (empty($config['dsn'])) {
                $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '')
            }

需要改为:

if (empty($config['dsn'])) {
                $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '').'/'.$this->dbName;
            }

kebenxiaoming avatar Jun 14 '22 06:06 kebenxiaoming

Mongodb数据库是:3.6.23版本

kebenxiaoming avatar Jun 14 '22 06:06 kebenxiaoming