mysql
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
A pure-Go MySQL and MariaDB database driver that plugs into Go's standard database/sql package so any Go app can talk to MySQL with no C dependencies and no extra setup.
Go-MySQL-Driver is a MySQL database driver for Go (also called golang). In Go, applications talk to databases through a standard interface in the language's built-in database/sql package, and this project plugs into that interface so Go programs can connect to MySQL or MariaDB servers without anything else doing the translation.
It is written entirely in Go with no C bindings, which makes it lightweight to install and easy to ship as a single compiled binary. It can connect to a database over plain TCP (both IPv4 and IPv6), Unix domain sockets, or a custom dial function you provide. The driver automatically handles broken connections, supports very large queries (over 16MB), works with prepared statements and large data fields, and offers secure LOAD DATA LOCAL INFILE handling with file allowlisting. Optional features include parsing MySQL date and time values into Go's time.Time type, placeholder interpolation, and zlib compression on the wire.
Once installed, a developer imports the package and opens a connection using a DSN string that follows the pattern username:password@protocol(address)/dbname?params. The README highlights connection-pool settings (SetConnMaxLifetime, SetMaxOpenConns, SetMaxIdleConns) that production apps should configure so that idle connections do not outlive the MySQL or middleware timeouts.
Someone would use this whenever they are writing a Go service, CLI, or batch job that needs to read from or write to MySQL, MariaDB, or compatible servers like TiDB. It targets Go 1.24 or newer and aims to support the three most recent Go releases. The project is open source. The full README is longer than what was provided.
Where it fits
- Connect a Go web service or CLI to a MySQL or MariaDB database using the standard database/sql interface with no CGo dependencies.
- Configure connection pool settings in a production Go app to prevent idle MySQL connections from being dropped by server timeouts.
- Use prepared statements and large blob fields in a Go application backed by MySQL with automatic reconnection on network failures.
- Connect to a MySQL database over a Unix socket in a containerized Go service for faster local communication.