Compatibility

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

AreaBehavior
ProtocolMySQL wire protocol on HARDHATDB_MYSQL_PORT (default 3306)
AccountsFirst boot creates one caching_sha2_password superuser. CREATE USER and GRANT add further accounts
TLSOptional. Set HARDHATDB_TLS_CERT and HARDHATDB_TLS_KEY together to require it
TransactionsBEGIN / COMMIT / ROLLBACK. In a cluster, an explicit transaction is forwarded as a whole
BinlogGTID stream, FLUSH BINARY LOGS, replica from an upstream MySQL source
Reads on a followerServed 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.

StatementWhere it runs
SHOW RAFT STATUSLocally, including on a follower. Includes suffrage
RAFT ADD VOTERLeader. A follower forwards it
RAFT ADD NONVOTERLeader. A follower forwards it. The new member copies the log and does not vote
RAFT REMOVE SERVERLeader. A follower forwards it. Drops a voter or a nonvoter
SHARD TABLE ... RANGEMeta 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 GLOBAL updates max_connections, net_read_timeout, net_write_timeout, and max_execution_time on this process. A connection keeps the socket timeout it was accepted with.
  • SOURCE_AUTO_POSITION cannot be disabled.
  • REPLICATE_REWRITE_DB is 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 reports standalone.