After a power cut or a container that was killed, I would like to know whether any table got damaged, without typing CHECK TABLE a hundred times. MariaDB has a client for that, and it is the same tool that used to be called mysqlcheck.
mariadb-check -u root -p --all-databases --check-only-changed
The docs describe it as a maintenance tool that checks, repairs, analyzes and optimizes many tables at once from the command line. It is basically a command-line interface to the CHECK TABLE, REPAIR TABLE, ANALYZE TABLE and OPTIMIZE TABLE statements. Checking is the default if you give no other action.
With -C / --check-only-changed it only looks at tables that have changed since the last check or that were not closed properly, which keeps the run short. --fast (-F) checks only tables that were not closed properly, and --quick (-q) avoids scanning the rows for wrong links, which the docs call the fastest check. For one database you can name it: mariadb-check -u root -p appdb.
The docs list a few limits to keep in mind:
- The server has to be running, unlike with
myisamchkandaria_chk. - It does not work with partitioned tables.
- Not all options are supported by all storage engines.
- The options for check, repair, analyze and optimize exclude each other.
I would stick to checking. --repair and --auto-repair exist, and the docs say --auto-repair repairs corrupted tables after all tables have been checked, but I want a fresh backup before something rewrites my tables. So: dump first, check second, repair last and only when needed.
Further reading: MariaDB documentation: mariadb-check