Skip to content

Unexpected EOF immediately after ping of MySQL server #1305

Closed
@CameronWise

Description

@CameronWise

Issue description

Tell us what should happen and what happens instead
Ping of server fails and prints bad connection

Example code

package main

import (
//    "log"
//    "time"
    "database/sql"
    "fmt"
    _ "github.com/go-sql-driver/mysql"
)

func main() {
    db, err := sql.Open("mysql", "root:rootPW@tcp(localhost:3306)/testdb")
    defer db.Close()
    if err != nil {
    panic(err.Error())
    }

    db.SetConnMaxLifetime(10000000)
    db.SetMaxIdleConns(0)
    db.SetMaxOpenConns(151)
    err = db.Ping()
    if err != nil {
        panic(err.Error()) // proper error handling instead of panic in your app
    }
    fmt.Println("Success?")
}

Error log

[mysql] 2022/02/04 19:18:05 packets.go:37: unexpected EOF
[mysql] 2022/02/04 19:18:05 packets.go:37: unexpected EOF
[mysql] 2022/02/04 19:18:05 packets.go:37: unexpected EOF
panic: driver: bad connection

goroutine 1 [running]:
main.main()
        /goserver/mysql.go:23 +0x13c

Configuration

Driver version (or git SHA):
current

Go version: run go version in your console
go version go1.17.6 linux/amd64

Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MySQL 5.7

Server OS: E.g. Debian 8.1 (Jessie), Windows 10
Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions