diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go index 583789b73..b8184d767 100644 --- a/pkg/common/db/unrelation/mongo.go +++ b/pkg/common/db/unrelation/mongo.go @@ -103,9 +103,9 @@ func buildMongoURI() string { maxPoolSize = fmt.Sprint(config.Config.Mongo.MaxPoolSize) } - uriFormat := "mongodb://%s/%s?maxPoolSize=%s&authSource=admin" + uriFormat := "mongodb://%s/%s?maxPoolSize=%s" if username != "" && password != "" { - uriFormat = "mongodb://%s:%s@%s/%s?maxPoolSize=%s&authSource=admin" + uriFormat = "mongodb://%s:%s@%s/%s?maxPoolSize=%s" return fmt.Sprintf(uriFormat, username, password, address, database, maxPoolSize) } return fmt.Sprintf(uriFormat, address, database, maxPoolSize) diff --git a/tools/component/component.go b/tools/component/component.go index e75c41365..b704ce845 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -171,10 +171,10 @@ func buildMongoURI() string { mongodbHosts := strings.Join(config.Config.Mongo.Address, ",") if username != "" && password != "" { - return fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", + return fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", username, password, mongodbHosts, database, maxPoolSize) } - return fmt.Sprintf("mongodb://%s/%s?maxPoolSize=%d&authSource=admin", + return fmt.Sprintf("mongodb://%s/%s?maxPoolSize=%d", mongodbHosts, database, maxPoolSize) }