Quick Start
From nothing to a heavy report answered from DBTrail's copy, in three steps you copy and paste in a terminal. No browser needed.
Three steps, all in a terminal. Copy each block, paste it, press Enter.
You need
- A Linux machine with Docker with Compose and the
mysqlclient. DBTrail runs there. - A MySQL login that can create users, for one step.
- Row binlogs and a primary key on every InnoDB table. Step 2 checks them.
- MySQL or Percona Server 8.0, 8.4 or 9.7 (not the 9.0 to 9.6 Innovation releases), or MariaDB 10.11 and newer.
Install DBTrail
the machine that will run DBTrailcurl -fsSL https://raw.githubusercontent.com/dbtrail/dbtrail/main/install.sh | sh
cd dbtrailIt waits until DBTrail answers. Ignore the browser page it may open.
Connect your MySQL
same terminalCheck the binlog. In mysql on your server (it is SQL), this must say ON,
ROW and FULL:
SHOW VARIABLES WHERE Variable_name IN ('log_bin', 'binlog_format', 'binlog_row_image');- Not
FULL? The fix. - RDS or Aurora: a parameter group sets them: read this first.
- At the first connect, a table with no primary key stops recording for the whole server: find them.
Say where it is. Change the first three lines: server, database, and the login that can create users. The last two make passwords for DBTrail.
export MYSQL_HOST=db1.example.com
export MYSQL_DB=shop
export MYSQL_ADMIN=root
export DBTRAIL_PW=$(openssl rand -hex 16)
export FWD_PW=$(openssl rand -hex 16)Keep this terminal open: every block below reads these lines.
Create DBTrail's users on your MySQL (what each one may do):
dbtrail reads the binlog and tables; dbtrail_fwd runs quick lookups and
what the copy cannot answer. It asks for the $MYSQL_ADMIN password.
mysql -h "$MYSQL_HOST" -u "$MYSQL_ADMIN" -p <<SQL
CREATE USER 'dbtrail'@'%' IDENTIFIED BY '$DBTRAIL_PW';
GRANT REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO 'dbtrail'@'%';
GRANT RELOAD, BACKUP_ADMIN, PROCESS, SHOW VIEW ON *.* TO 'dbtrail'@'%';
CREATE USER 'dbtrail_fwd'@'%' IDENTIFIED BY '$FWD_PW';
GRANT SELECT ON $MYSQL_DB.* TO 'dbtrail_fwd'@'%';
SQL- MariaDB: leave out
BACKUP_ADMIN. RDS or Aurora: another line forRELOAD. - App writes through DBTrail? Give
dbtrail_fwdits grants instead ofSELECT(the risk).
MySQL on this same machine? Without these two, server add stops with
connect: connection refused. They change MySQL's config to listen on every
address, and restart it, offline for a few seconds (what changes).
export MYSQL_HOST=host.docker.internal
printf '[mysqld]\nbind-address = 0.0.0.0\n' | sudo tee /etc/mysql/mysql.conf.d/zz-dbtrail.cnfsudo systemctl restart mysqlConnect it to DBTrail, through a file only you can read, deleted after.
cat > dbtrail-server.cnf <<EOF
[client]
host=$MYSQL_HOST
user=dbtrail
password=$DBTRAIL_PW
[dbtrail-forward]
user=dbtrail_fwd
password=$FWD_PW
EOF
chmod 600 dbtrail-server.cnf
./dbtrail server add --defaults-file dbtrail-server.cnf --name "$MYSQL_DB"
rm dbtrail-server.cnfIt checks your MySQL, says what to fix, starts recording changes, and prints
the mysql line and password of DBTrail's MySQL port.

Keep that password: it is shown once. ./dbtrail port new-password makes another.
Make the first copy.
./dbtrail snapshot run "$MYSQL_DB"
./dbtrail snapshot schedule "$MYSQL_DB" --every 1hThe first line reads every table once. Writes may wait a moment as it starts:
pick a quiet time (why).
On MariaDB, not while an ALTER TABLE runs (why).
The second keeps the copy current from the recorded changes.
Run a heavy report
the DBTrail machine, same terminalmysql -h 127.0.0.1 -P 3309 -u "$MYSQL_DB" -p "$MYSQL_DB"Paste the password from step 2. Then a total over one of your biggest tables:
SELECT status, count(*) FROM orders GROUP BY status;
The copy answers it, without loading your MySQL. To see who answered, right after:
SHOW ROUTER STATUS;last_answer says copy.

In a browser instead
Same steps at http://127.0.0.1:8090: pick a username and password, and the form to add your server opens.
Next
- Connect your application: heavy queries to DBTrail, the rest to your MySQL, on one connection.
- Undo a wrong change: the SQL that puts rows back.
- Every
dbtrailcommand, and the same setup as configuration for a server you keep running. - Remove it: from the
dbtrailfolder,docker compose down -vstops DBTrail and deletes its data.
Introduction
Turn minutes of waiting on reports or any heavy query into seconds. Same SQL, same mysql client, nothing to install on your MySQL or to migrate.
What you can do
Reports, queries over years of data and deep pages come back in seconds instead of minutes, from your MySQL client. And undo, restore and time travel come with it.