Golang, mysql: Error 1040: Too many connections

前端 未结 5 1731
终归单人心
终归单人心 2021-02-01 17:57

I\'m using the github.com/go-sql-driver/mysql driver for go.

I open a database:

db, err := sql.Open(\"mysql\", str)

Then I have two fun

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 18:13

    Try to make prepared statements db.Prepare(query string) (*Stmt, error) and than stmt.Query or stmt.Exec and than stmt.Close to reuse connections.

提交回复
热议问题