Browse Source

修改连接charset

master v0.5.5
guzeng 3 years ago
parent
commit
75e7036854
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      conn.go

+ 1
- 1
conn.go View File

@ -22,7 +22,7 @@ func Connect(DBHOST, DBUSER, DBPWD, DBNAME, DBPORT string, conns ...int) error {
if DBHOST != "" && DBUSER != "" && DBPWD != "" && DBPORT != "" { //&& DBNAME != "" if DBHOST != "" && DBUSER != "" && DBPWD != "" && DBPORT != "" { //&& DBNAME != ""
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
DB, dbConnErr = sql.Open("mysql", DBUSER+":"+DBPWD+"@tcp("+DBHOST+":"+DBPORT+")/"+DBNAME+"?charset=utf8")
DB, dbConnErr = sql.Open("mysql", DBUSER+":"+DBPWD+"@tcp("+DBHOST+":"+DBPORT+")/"+DBNAME+"?charset=utf8mb4")
if dbConnErr != nil { if dbConnErr != nil {
log.Println("ERROR", "can not connect to Database, ", dbConnErr) log.Println("ERROR", "can not connect to Database, ", dbConnErr)
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)


Loading…
Cancel
Save