Go MySQL Driver is a MySQL driver implementation for Go's database/sql package, providing native connectivity to MySQL and MariaDB databases. Written entirely in Go without C bindings, it implements Go's database/sql/driver interface, allowing developers to use the standard database/sql API for MySQL operations. The driver supports MySQL 5.7 and higher, MariaDB 10.5 and higher, and also works with TiDB, though TiDB support is maintained by PingCAP rather than the go-sql-driver maintainers.
The driver offers lightweight performance through its pure Go implementation and supports multiple connection protocols including TCP/IPv4, TCP/IPv6, Unix domain sockets, and custom protocols via DialFunc. It handles automatic connection pooling through the database/sql package and includes automatic recovery from broken connections. The driver can process queries larger than 16MB and provides full sql.RawBytes support for efficient data handling. It includes intelligent LONG DATA handling in prepared statements and supports zlib compression for network traffic reduction.
Security features are built into the driver's design. It provides secure LOAD DATA LOCAL INFILE support with file allowlisting and io.Reader support, preventing unauthorized file access. The driver supports optional time.Time parsing, optional placeholder interpolation, and various authentication methods including native passwords and cleartext passwords when explicitly enabled. Configuration options allow fine-grained control over connection behavior, including charset and collation settings for proper Unicode support.
Connection management is a key focus area. The driver requires developers to set db.SetConnMaxLifetime() to ensure connections are safely closed before MySQL server, OS, or middleware closes them, with a recommended timeout shorter than five minutes. The db.SetMaxOpenConns() setting is highly recommended to limit connection usage, and db.SetMaxIdleConns() should typically match SetMaxOpenConns() to prevent excessive connection churn. Additional control is available through db.SetConnMaxIdleTime() for more rapid idle connection closure.
The Data Source Name (DSN) format follows a common pattern with optional components for password, protocol, address, and parameters. All values except the database name are optional, allowing flexible configuration from minimal to fully specified connection strings. The driver includes context.Context support and ColumnType support for advanced query operations.
According to GitGenius activity tracking, the repository shows median issue and pull request response latency of 21 hours across 105 tracked items, though mean latency is significantly higher at 11472.9 hours, indicating occasional slower responses on some items. The most active contributor tracked is methane with 161 events, followed by shogo82148 with 8 events and modelorona with 6 events. Enhancement requests and database/sql issues are the most common tracked labels with 4 items each, while help wanted items total 3. The repository shares contributors with major projects including microsoft/vscode, golang/go, and rust-lang/rust, indicating its importance in the broader Go ecosystem.