Compatibility
HardhatDB speaks the MySQL wire protocol. SQL runs in go-mysql-server and the rows are stored in Badger. Use any client that can talk to MySQL: the mysql CLI, drivers, and GUI tools. Moving an existing database is in Migration.
What matches MySQL
| Area | Behavior |
|---|---|
| Protocol | MySQL wire protocol on HARDHATDB_MYSQL_PORT (default 3306) |
| Accounts | First boot creates one caching_sha2_password superuser. CREATE USER and GRANT add further accounts |
| TLS | Optional. Set HARDHATDB_TLS_CERT and HARDHATDB_TLS_KEY together to require it |
| Transactions | BEGIN / COMMIT / ROLLBACK. In a cluster, an explicit transaction is forwarded as a whole |
| Binlog | GTID stream, FLUSH BINARY LOGS, replica from an upstream MySQL source |
| Reads on a follower | Served locally after this node applies its commit index. Another node can lag by one Raft heartbeat. HARDHATDB_READ_FROM=leader forwards ordinary reads to the leader |
What is HardhatDB-specific
These statements are not part of the MySQL grammar. The server recognizes them before the SQL parser runs. See SQL Reference.
| Statement | Where it runs |
|---|---|
SHOW RAFT STATUS | Locally, including on a follower. Includes suffrage |
RAFT ADD VOTER | Leader. A follower forwards it |
RAFT ADD NONVOTER | Leader. A follower forwards it. The new member copies the log and does not vote |
RAFT REMOVE SERVER | Leader. A follower forwards it. Drops a voter or a nonvoter |
SHARD TABLE ... RANGE | Meta group, when HARDHATDB_META_ADDR is set |
What does not follow MySQL
- The server accepts views, triggers, routines, and events. A load or dump recreates them and removes
DEFINER. SET GLOBALupdatesmax_connections,net_read_timeout,net_write_timeout, andmax_execution_timeon this process. A connection keeps the socket timeout it was accepted with.SOURCE_AUTO_POSITIONcannot be disabled.REPLICATE_REWRITE_DBis rejected.- A follower that has not received the accounts yet rejects every login.
- A data directory opens when its format matches this binary. A later layout bump refuses the old directory.
- Raft admin statements fail on a standalone process, except
SHOW RAFT STATUS, which reportsstandalone.