Go-MySQL-Driver

A pure Go implementation of the MySQL wire protocol, used as the database/sql driver for MySQL, MariaDB, and TiDB.

Library
Go
vv1.10.1
15,282stars
Mozilla Public License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity76
Maintenance60
Community92
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture85
Code Quality90
Innovation75
Learning Curve80

Go-MySQL-Driver implements Go’s database/sql/driver interface entirely in Go, with no cgo or C bindings, so it cross-compiles cleanly and runs anywhere the Go toolchain does. Importing it for its side effect registers a mysql driver with database/sql, after which the standard library’s connection pooling, prepared statements, and query APIs work against MySQL, MariaDB, or TiDB without any driver-specific code in the caller.

Beyond the baseline driver contract, it handles the practical edges of talking to a real MySQL server: TLS negotiation, zlib compression, LOAD DATA LOCAL INFILE with an explicit file allowlist, automatic reconnection on broken connections, and full context.Context support for cancellation and timeouts. Configuration is driven by a DSN string or a typed Config struct, both parsed and validated the same way, so applications can choose whichever fits their setup.

What You Get

  • A database/sql/driver implementation registered under the mysql driver name via a blank import
  • DSN parsing and a typed Config/FormatDSN API for building connection strings programmatically
  • TLS support, including custom tls.Config registration for verified or self-signed certificates
  • Optional zlib connection compression and pluggable custom dial functions via RegisterDialContext
  • Context-aware query cancellation and configurable read/write timeouts
  • Secure LOAD DATA LOCAL INFILE support with explicit file and reader allowlisting

Common Use Cases

  • Backing a Go web service’s database/sql connection pool with a MySQL or MariaDB database
  • Connecting to TiDB, which speaks the MySQL wire protocol, for horizontally scaled workloads
  • Streaming large result sets or bulk-loading data via LOAD DATA LOCAL INFILE from an io.Reader
  • Using sql.RawBytes and prepared statements to move large payloads without excess allocation

Under The Hood

Architecture The driver is a flat, single-package implementation of Go’s database/sql/driver interfaces (driver.go, connector.go, connection.go, statement.go, transaction.go, rows.go). MySQLDriver.Open/OpenConnector parse a DSN into a Config and hand it to an internal connector, whose Connect method performs the handshake and returns a mysqlConn that owns the network connection, protocol buffer, and per-connection state (capability flags, sequence numbers, compression). packets.go implements the wire protocol framing and packet types on top of a small buffer abstraction, and auth.go isolates the various MySQL authentication plugins (native password, caching_sha2, cleartext) behind a common negotiation path. This keeps protocol concerns, connection lifecycle, and the database/sql adapter surface in clearly separate files despite the single-package layout, so a change to authentication or packet framing doesn’t ripple into the sql.driver glue code.

Tech Stack The module targets Go 1.24+ and declares exactly one external dependency, filippo.io/edwards25519, used for Ed25519 curve arithmetic in newer MySQL authentication plugins — everything else, including TCP/TLS handling, zlib compression, and DSN parsing, is implemented with the Go standard library (net, crypto/tls, compress/zlib, context). There is no ORM or query-builder layer; the driver operates purely at the database/sql/driver boundary, so any Go code using database/sql gets MySQL/MariaDB/TiDB connectivity by importing the package for its side effect and calling sql.Open("mysql", dsn).

Code Quality The repository ships 14 _test.go files with roughly 167 test functions, including fuzz tests for DSN parsing (dsn_fuzz_test.go) and a benchmark suite, exercised in CI against a real matrix of MySQL (5.7 through 9.0) and MariaDB (10.5 through 12.3 LTS) versions across three Go releases and three operating systems. A dedicated lint job runs staticcheck on every push and pull request. Errors are exposed as typed sentinel values (ErrInvalidConn, ErrPktTooLarge, etc.) and a MySQLError type carrying the server’s numeric code and SQLSTATE, rather than opaque strings, and connection-layer failures are explicitly funneled through markBadConn so database/sql knows to retry on a fresh connection instead of silently reusing a broken one.

What Makes It Unique Unlike drivers that wrap a C client library via cgo, this is a from-scratch reimplementation of the MySQL wire protocol in pure Go, which is what lets it cross-compile to any Go-supported platform without a C toolchain or shared library at runtime. It also treats operational safety as a first-class concern rather than an afterthought — LOAD DATA LOCAL INFILE, a feature that has been a source of real-world SQL injection and file-disclosure vulnerabilities in other drivers, requires callers to explicitly allowlist file paths or register an io.Reader, closing off the class of exploit where a malicious server or query could read arbitrary client-side files.

Used by 33 apps in this directory

Go
73%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

36,892

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
91
Repo Health
76
Technical
67
Dependency
Built with
Go73%
Vue27%
Updated 3 days ago
MIT

Alexandrie

Knowledge Management · Note Taking · Collaboration

2,752

The open-source, offline-first Notion, Obsidian & Confluence alternative with multi-tenant teams, OIDC/SSO, and one-command Docker deployment.

View details
86
Repo Health
73
Technical
0
Dependency
Go
60%
Apache 2.0

Apache Answer

Community

15,679

Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility

View details
85
Repo Health
78
Technical
68
Dependency
Built with
Go60%
TypeScript36%
Updated 1 weeks ago
Go
85%
Apache 2.0

Argo Workflows

Devops · Data Engineering

16,978

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
67
Dependency
Built with
Go85%
TypeScript11%
Updated 3 days ago
Go
82%
Apache 2.0

Authelia

Security · Authentication

28,964

OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.

View details
91
Repo Health
81
Technical
76
Dependency
Built with
Go82%
TypeScript16%
Updated 2 days ago
Go
50%
MIT

Bytebase

Devops

14,484

An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.

View details
92
Repo Health
73
Technical
68
Dependency
Built with
Go50%
TypeScript42%
Updated 2 days ago
Go
33%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

12,344

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go33%
Rust26%
C23%
Updated 3 days ago
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,440

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
91
Repo Health
9
Technical
65
Dependency
Built with
Go79%
Shell19%
Updated 2 days ago
Go
37%
MIT

ezBookkeeping

Invoicing Finance

5,578

Lightweight self-hosted personal finance manager with AI receipt scanning, multi-currency support, and MCP integration for complete data privacy.

View details
88
Repo Health
80
Technical
72
Dependency
Built with
Go37%
Vue34%
TypeScript25%
Updated 3 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search