Skip to content

Commit

Permalink
Merge pull request #1 from Ccheers/master
Browse files Browse the repository at this point in the history
Update mysql.go
  • Loading branch information
xzghua committed Feb 12, 2020
2 parents e8f3ca2 + 3b76c14 commit ec1aae7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conn/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func InitMysql(options ...Sp) (*xorm.Engine,error){
option(q)
}

dataSourceName := q.UserName + ":" + q.Password + "@/" + q.DataBase + "?charset=utf8"
dataSourceName := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", q.UserName, q.Password, q.Host, q.Port, q.DataBase)
engine, err := xorm.NewEngine("mysql", dataSourceName)
if err != nil {
zgh.ZLog().Error("mysql","初始化数据库,创建连接异常:"+err.Error())
Expand Down Expand Up @@ -140,4 +140,4 @@ func SqlDump(fileName string,filePath string) error {
return err
}
return nil
}
}

0 comments on commit ec1aae7

Please sign in to comment.