Repolode
go-mysql-org

go-mysql-org/go-mysql

A pure Go library for speaking the MySQL and MariaDB network protocol, with binlog replication, a client, a fake server and a database/sql driver.

Stars
4,974
Forks
1,097
Open issues
166
Last commit
yesterday

What is it?

go-mysql is a pure Go library that implements the MySQL and MariaDB network protocol. It lets Go programs connect to a MySQL server, act as a replica to read the binlog stream, or build their own MySQL-compatible server endpoints.

The replication package processes events from a binlog stream using file position or GTID, which suits keeping caches or search indexes in sync with a database. The canal package builds on this to dump existing data and then apply incremental row changes, and the project includes example commands such as a mysqldump-like tool written in Go.

Beyond replication, the repository provides a simple client with connection pooling and streaming SELECT results, a server package for building MySQL proxies, and a database/sql driver with configurable DSN options such as TLS and compression.

Key features

  • 01Reads binlog event streams by file position or GTID for MySQL and MariaDB.
  • 02Incremental data sync framework (canal) that dumps existing data then applies row changes.
  • 03Simple MySQL client with connection pool and streaming SELECT results.
  • 04Server package for building a MySQL-compatible endpoint or proxy.
  • 05database/sql driver with TLS, zlib/zstd compression and timeout options.

Use cases

  • Syncing MySQL data into Redis or Elasticsearch by consuming binlog changes.
  • Building a MySQL proxy or a fake MySQL server for testing in Go.
  • Writing Go backup or export tools that resemble mysqldump.
  • Using MySQL from Go code through the standard database/sql interface.

Quick start

  1. 1

    Import the library packages in your Go project

  2. 2

    Build the bundled example applications from the project root

    make build

In collections

Topics

FAQ

What is go-mysql?
A pure Go library for speaking the MySQL and MariaDB network protocol, with binlog replication, a client, a fake server and a database/sql driver. go-mysql is a pure Go library that implements the MySQL and MariaDB network protocol. It lets Go programs connect to a MySQL server, act as a replica to read the binlog stream, or build their own MySQL-compatible server endpoints.
Is go-mysql free to use? What license does it have?
go-mysql is open source under the MIT license. Check the license terms before using it in commercial products.
Is go-mysql still maintained?
Actively maintained. The last commit to go-mysql was on Nov 6, 2026.
What can I use go-mysql for?
Syncing MySQL data into Redis or Elasticsearch by consuming binlog changes. Building a MySQL proxy or a fake MySQL server for testing in Go. Writing Go backup or export tools that resemble mysqldump. Using MySQL from Go code through the standard database/sql interface.
How do I install go-mysql?
Import the library packages in your Go project Build the bundled example applications from the project root: make build
Where can I get go-mysql?
The source code and installation instructions are on GitHub: https://github.com/go-mysql-org/go-mysql

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects