Skip to content

Commit 32fdd30

Browse files
committed
Update mysql connection string & add missing port config option
1 parent 3a962bf commit 32fdd30

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

msq/connection.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package msq
33
import (
44
"errors"
55
"fmt"
6+
"strconv"
67

78
"github.com/jinzhu/gorm"
89
_ "github.com/jinzhu/gorm/dialects/mysql"
@@ -12,6 +13,7 @@ import (
1213
type ConnectionConfig struct {
1314
Type string
1415
Host string
16+
Port int
1517
Username string
1618
Password string
1719
Database string
@@ -73,10 +75,11 @@ func (c *Connection) getConnectionString() string {
7375

7476
if dbType == "mysql" {
7577
return fmt.Sprintf(
76-
"%s:%s@%s/%s?charset=%s&parseTime=True&loc=%s",
78+
"%s:%s@tcp(%s:%s)/%s?charset=%s&parseTime=True&loc=%s",
7779
c.Config.Username,
7880
c.Config.Password,
7981
c.Config.Host,
82+
strconv.Itoa(c.Config.Port),
8083
c.Config.Database,
8184
c.Config.Charset,
8285
c.Config.Locale,

0 commit comments

Comments
 (0)