diff --git a/dumpling/export/config.go b/dumpling/export/config.go index efd41bcd3082e..5c36557f6a4d1 100644 --- a/dumpling/export/config.go +++ b/dumpling/export/config.go @@ -8,6 +8,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "net" "strconv" "strings" "text/template" @@ -199,8 +200,9 @@ func (conf *Config) String() string { func (conf *Config) GetDSN(db string) string { // maxAllowedPacket=0 can be used to automatically fetch the max_allowed_packet variable from server on every connection. // https://github.com/go-sql-driver/mysql#maxallowedpacket - dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?collation=utf8mb4_general_ci&readTimeout=%s&writeTimeout=30s&interpolateParams=true&maxAllowedPacket=0", - conf.User, conf.Password, conf.Host, conf.Port, db, conf.ReadTimeout) + hostPort := net.JoinHostPort(conf.Host, strconv.Itoa(conf.Port)) + dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?collation=utf8mb4_general_ci&readTimeout=%s&writeTimeout=30s&interpolateParams=true&maxAllowedPacket=0", + conf.User, conf.Password, hostPort, db, conf.ReadTimeout) if len(conf.Security.CAPath) > 0 { dsn += "&tls=dumpling-tls-target" }