MygramDB is an in-memory full-text search engine kept in sync with MySQL or MariaDB through GTID binlog replication. MySQL/MariaDB stays the source of truth and keeps every write; search traffic goes to MygramDB over TCP or HTTP, with no change to the application's write path.
📖 Documentation · Getting started · Docker deployment
- N-gram full-text search — boolean and phrase queries, filters, sorting, BM25 ranking, highlighting, fuzzy matching, FACET and synonyms, all from memory. Query syntax · Queries
- GTID binlog replication — follows INSERT, UPDATE, DELETE and supported DDL from MySQL 8.4/9.7/26.x (tagged GTIDs included) and MariaDB 10.11+/11.x/12.x. MySQL replication
- Snapshot and resume —
SYNCbuilds the initial index from the table;DUMP SAVE/DUMP LOADrestart from a saved state and resume at the recorded GTID. Snapshot - TCP and HTTP surfaces — a text protocol with search and administrative commands, and an HTTP API for search, documents, health and metrics. Protocol · HTTP API
- Multilingual text — ICU NFKC normalization, so CJK and other scripts index and match consistently. How it works
- Client libraries — C/C++ ships in this repository; Go, Node.js and Python live alongside it. go-mygram-client · node-mygramdb-client · python-mygramdb-client
- Shared binlog libraries — the binlog wire format is decoded by libmybinlog, which refuses malformed input instead of guessing; mysql-event-stream is a standalone CDC engine for MySQL/MariaDB with Node.js and Python bindings, built on the same decoding. libmybinlog · mysql-event-stream
The source server needs log_bin=ON, binlog_format=ROW, binlog_row_image=FULL, binlog_row_metadata=FULL and binlog_checksum=CRC32, plus log_replica_updates (MariaDB: log_slave_updates) when the source is itself a replica. MygramDB checks these at startup and refuses to start when one is missing.
RPM (EL9/EL10) and DEB (Ubuntu 22.04/24.04) packages for x86_64 and arm64 are attached to each GitHub release:
sudo rpm -i mygramdb-*.el9.x86_64.rpm # RHEL / AlmaLinux / Rocky Linux 9
sudo apt install ./mygramdb_*_amd64.deb # UbuntuThe container image is ghcr.io/libraz/mygram-db (linux/amd64 and linux/arm64):
docker pull ghcr.io/libraz/mygram-db:latestCopy the example configuration, set the MySQL connection, the tables to index and network.allow_cidrs, then start the service and load the existing rows:
sudo cp /etc/mygramdb/config.yaml.example /etc/mygramdb/config.yaml
sudoedit /etc/mygramdb/config.yaml
sudo systemctl enable --now mygramdb
mygram-cli -h 127.0.0.1 -p 11016127.0.0.1:11016> SYNC articles
OK SYNC STARTED table=mydb.articles
127.0.0.1:11016> SEARCH articles hello world
OK RESULTS 3 101 205 387
Once SYNC STATUS reports COMPLETED, binlog replication keeps the index current. The Getting started guide walks through the full configuration; for a Docker Compose setup with a bundled MySQL, see Docker deployment.
MygramDB reads these variables itself, and they take precedence over the corresponding configuration keys:
| Variable | Key it overrides |
|---|---|
MYGRAM_MYSQL_HOST / MYGRAM_MYSQL_PORT |
mysql.host / mysql.port |
MYGRAM_MYSQL_USER / MYGRAM_MYSQL_PASSWORD |
mysql.user / mysql.password |
MYGRAM_MYSQL_DATABASE |
mysql.database |
MYGRAM_API_ADMIN_TOKEN |
api.admin_token |
A variable set to the empty string counts as unset. API_ADMIN_TOKEN in .env is a different thing: the Docker entrypoint writes it into the generated config.yaml, so use it with the shipped compose files and MYGRAM_API_ADMIN_TOKEN when running the binary yourself. CONFIG VERIFY checks the file on its own without these overrides, so a configuration that relies on them is reported as incomplete there even though the server starts from it.
The MySQL connection is fixed at startup. Changing mysql.host or mysql.port takes a restart, automatic reconnection never moves to another endpoint, and a change of source server UUID is rejected.
The shipped Docker environment listens on localhost only. A non-loopback TCP bind requires a high-entropy API_ADMIN_TOKEN, and the configuration is rejected without one. A TCP connection must send AUTH <token> before any administrative command (SET, SHOW VARIABLES, DUMP, SYNC, REPLICATION, OPTIMIZE, CACHE, CONFIG, DEBUG); HTTP POST /optimize, GET /config and GET /replication/status take the same token as Authorization: Bearer <token>. Docker Compose refuses to start until the placeholder token in .env is replaced.
Keep the TCP port behind a restrictive NETWORK_ALLOW_CIDRS list on a private or encrypted network: the protocol does not encrypt the AUTH token, and an allow-all IPv4 or IPv6 list combined with a public bind is rejected. Under Docker the address the server sees is the bridge gateway, not the client host, so the shipped compose files allow the bridge range and limit exposure through loopback port mappings. Network security
make build # configure and build into build/
make test # fast tier, excluding SLOW and LOAD tests
make e2e-test # end-to-end suite against MySQL in Docker
make install # install binaries and filesBuild prerequisites and CMake options are listed in the development guide.
The documentation lives at mygramdb.libraz.net, in English and Japanese.
- Learn — Getting started · How it works · Architecture
- Guides — Installation · Docker deployment · Operations · Upgrading to v1.12
- Reference — Configuration · Protocol · HTTP API · Client library · Release notes