This morning I was planning to check the integrity of a snapshot of a MySQL database that runs on EC2 using EBS, and I accidentally stumbled upon a fast way to quickly find certain types of problems with a backup.
My plan was to use CHECK TABLE on all of the tables
to verify the integrity of the backup. The simplest way to run
CHECK TABLES on an entire database is like this:
mysqlcheck -c --all-databases
Rather than using that command, I decided to generate a bunch of
individual CHECK TABLE statements dynamically by
running a query on the information_schema.tables
table. Why do it that way? It gives me the flexibility to check a
specific schema first, or check the smallest or most frequently
updated tables first, etc.
So I ran this command to generate my CHECK TABLE
script:
select concat('check table ', table_schema, …