MySQL: Checksum Table

Sometimes it is required to compare two tables to check if they are the same or not.

For this you can calculate and compare the checksums of each table, using the CHECKSUM TABLE command in MySQL.

This command is especially useful if you’re using MySQL replication and want to ensure that master and slave are consistent by verifying that their tables are identical.

Read Lock: During checksumming, the table is locked with a read lock and it could take a long time if a table is large!

Cool Tip: Check the size of a table in MySQL beforehand! Read more →

MySQL: CHECKSUM TABLE

Run the CHECKSUM TABLE command against a table to calculate its checksum:

mysql> CHECKSUM TABLE table_name;

Sample output:

+--------------------+------------+
| Table              | Checksum   |
+--------------------+------------+
| db_name.table_name | 0123456789 |
+--------------------+------------+
1 row in set (0.00 sec)