brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mysqldump --no-data --skip-dump-date exports a database schema you can keep in git

Database
~/tips/tip-database-mysqldump-no-data-schema

mysqldump --no-data --routines --skip-dump-date mydb > schema.sql

Writes only the table and routine definitions of a MySQL or MariaDB database, in a form that diffs cleanly.

A schema file in version control shows me what changed between two releases of an app. mysqldump can write one for MySQL and MariaDB.

mysqldump --no-data --routines --skip-dump-date mydb > schema.sql

--no-data writes the CREATE statements and no rows. --skip-dump-date removes the timestamp from the last line of the file, so running the dump twice on an unchanged database gives identical files and a clean git diff.

Triggers come with the table definitions, but stored routines only appear when you add --routines. Auto-increment counters can still show up as changed lines in the CREATE TABLE statements.

Further reading: MySQL Reference Manual: mysqldump

More Database tips mariadb -e 'CREATE DATABASE IF NOT EXISTS blog' mariadb-dump --no-create-info --insert-ignore shop orders > orders-rows.sql SELECT table_schema, table_name, CHECKSUM TABLE shop.orders; services: All Database tips (53) All topics

Link