Home » Mysql » How do I see the differences between 2 MySQL dumps?

How do I see the differences between 2 MySQL dumps?

Posted by: admin November 30, 2017 Leave a comment

Questions:

I have 2 MySQL dump files. I want to find the table data difference between 2 tables.

Answers:

Use a DIFF tool – here are some graphical ones (both are free):

Questions:
Answers:

run mysqldump with “–skip-opt” to get the 2 dumps files i.e:

mysqldump --skip-opt -u $MY_USER -p$MY_PASS mydb1 > /tmp/dump1.sql

mysqldump --skip-opt -u $MY_USER -p$MY_PASS mydb2 > /tmp/dump2.sql

compare using these diff options:

diff -y --suppress-common-lines /tmp/dump1 /tmp/dump2

Questions:
Answers:

Maybe you can give a tool called mysqldiff a go, I haven’t tried it myself yet but it’s been on my list for a while.

Questions:
Answers:

In order to compare 2 mysql diffs they need to be done in a certain manner, so that the order is in a defined way and non relevant data is omitted.

This was at one point not totally possible with mysqldump, I am not sure if this has changed in the meantime.

One good tool for the job is pydumpy https://code.google.com/p/pydumpy/ (mirror: https://github.com/miebach/pydumpy)

If you want to compare to an old dump, like in the question, you could first create a temporary database from the dump and then start there.