File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -131,10 +131,13 @@ type Config struct {
131
131
func NewInitConfig () * Config {
132
132
// check mysql version is supported or not and then get parse mysql semver version
133
133
var mysqlSemVer semver.Version
134
+
134
135
if ver := getEnvValue ("MYSQL_VERSION" ); ver == utils .InvalidMySQLVersion {
135
136
panic ("invalid mysql version, currently we only support 5.7 or 8.0" )
136
137
} else {
137
- mysqlSemVer , err := semver .Parse (ver )
138
+ var err error
139
+ // Do not use := here, it will alloc a new semver.Version every time.
140
+ mysqlSemVer , err = semver .Parse (ver )
138
141
if err != nil {
139
142
log .Info ("semver get from MYSQL_VERSION is invalid" , "semver: " , mysqlSemVer )
140
143
panic (err )
@@ -310,7 +313,8 @@ func (cfg *Config) buildXenonConf() []byte {
310
313
}
311
314
312
315
hostName := fmt .Sprintf ("%s.%s.%s" , cfg .HostName , cfg .ServiceName , cfg .NameSpace )
313
-
316
+ // Because go-sql-driver will translate localhost to 127.0.0.1 or ::1, but never set the hostname
317
+ // so the host is set to "127.0.0.1" in config file.
314
318
str := fmt .Sprintf (`{
315
319
"log": {
316
320
"level": "INFO"
@@ -333,7 +337,7 @@ func (cfg *Config) buildXenonConf() []byte {
333
337
"admin": "root",
334
338
"ping-timeout": %d,
335
339
"passwd": "%s",
336
- "host": "localhost ",
340
+ "host": "127.0.0.1 ",
337
341
"version": "%s",
338
342
"master-sysvars": "%s",
339
343
"slave-sysvars": "%s",
You can’t perform that action at this time.
0 commit comments