Skip to content

gh-ost

A tool that changes a MySQL table's structure while the app keeps running, without triggers.

Stars
13.6k
Forks
1.4k
Licence
MIT
Language
Go
Last update
10 days ago
Type
Dev tool

What it is

gh-ost is a command-line tool from GitHub for altering the structure of large MySQL tables while the database keeps serving traffic. It builds a copy of the table with the new structure, copies rows over in small batches, and replays ongoing changes from the binary log onto the copy. When the copy is caught up, it swaps the tables. Unlike many older tools, it does not use database triggers, which the README says carry many limitations and risks.

  • Add or drop a column on a large production table without locking writes for long periods
  • Run a noop migration to check that a change is valid before executing it
  • Test a migration on a replica and compare the resulting tables before running it on the master
  • Postpone the cut-over step until a planned maintenance window using a flag file

Great for

  • Teams running large MySQL tables where a blocking ALTER would cause unacceptable downtime
  • Database operators who want to pause, throttle, or reconfigure a migration while it runs
  • Teams that want to rehearse migrations on a replica before touching production
  • Operators who need to schedule the final table swap for a convenient time

Not ideal for

  • Small tables where a plain ALTER TABLE is fast enough and simpler to use, since gh-ost adds operational steps
  • Anyone not running MySQL, since the tool is specifically for MySQL
  • Beginners without MySQL replication and binary log experience, since configuration requires understanding of the master, replicas, and binlog format
Step-by-step guide: how to use gh-ostInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Download the app

    You'll need: MySQL with binary logging enabled (per the README's requirements doc; details not in the truncated README)

    Clone the repository

    git clone https://github.com/github/gh-ost
  2. 2

    Run it

    • Download the latest release archive or package from the releases page, or build from source with script/build
    • Read the requirements and limitations doc and the cheatsheet before running anything
    • Run a noop migration first to confirm the change is valid
    • Run the same migration with --test-on-replica on a replica to build confidence
    • Run the real migration with --execute once the noop and replica tests pass
  3. 3

    Get the most out of it

    • Use --exact-rowcount for accurate progress indication
    • Use --postpone-cut-over-flag-file to control when the table swap happens
    • Use the interactive commands to throttle or reconfigure a migration while it runs
    • Query status over the unix socket or TCP to audit progress
    • Use external hooks to connect gh-ost to your own environment

Downloads

Strengths

  • Does not rely on triggers, which the README describes as a source of limitations and risks
  • Supports pausing and throttling, with the README saying writes truly cease while throttled
  • Offers interactive commands and status queries over a unix socket or TCP while it runs

Trade-offs

  • The README notes requirements and limitations are documented separately, so operators must read those docs before use
  • Requires understanding of MySQL replication setup to choose the right run mode
  • Binaries are documented for Linux and macOS; the README does not describe Windows support

How it compares

ProjectStarsTypeLevelUpdatedBest for
gh-ost (this)13.6kDev tooladvanced10 days agoTeams running large MySQL tables where a blocking ALTER would cause unacceptable downtime
sqlc18.4kDev toolintermediate4 days agoGo developers who prefer writing plain SQL over using an ORM
gogs47.9kAppintermediate5 days agoSmall teams that want a private Git server on their own hardware
typeorm36.7kLibraryintermediate8 days agoNode.js or TypeScript developers building apps backed by a relational database
sequelize30.3kLibraryintermediate5 days agoNode.js backend developers who use a relational SQL database
knex20.3kLibraryintermediate4 months agoNode.js developers who need to talk to a SQL database from application code

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.