unexpected EOF and busy buffer in (go-sql-driver/mysql) packets.go

Viewed 5656

I am getting the unexpected EOF and busy buffer error in go-sql-driver/mysql despite after setting the SetConnMaxLifetime, SetMaxIdleConns and SetMaxOpenConns as suggested here. Can anyone tell me the proper solution of this issue nothing seems to work for me?

db, err := sql.Open("mysql", "USERNAME:PASSWORD@tcp(IP:PORT)/DB?charset=utf8")
checkErr(err)
db.SetConnMaxLifetime(time.Second * 5)
db.SetMaxIdleConns(0)
db.SetMaxOpenConns(151)

rows, err := db.Query("Select col1, col2, col3 from tbl")
checkErr(err)

for rows.Next() {
    var col1 string     
    var col2 int32
    var col3 uint64

    err = rows.Scan(&col1, &col2, &col3)
    checkErr(err)  
    Process(col1, col2, col3)

}
3 Answers

None of these worked for me. I have used the Docker container then I tried to log in to it from the local machine with MySQL client.

mysql -h localhost -P 3306 --protocol=tcp

After this go programme worked fine.

Related