GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Comparing/Diff-ing MySQL Tables (https://gfy.com/showthread.php?t=1256077)

Cyber Fucker 04-05-2017 01:05 PM

Comparing/Diff-ing MySQL Tables
 
What are the best tools to do it? I need this badly.

A few days ago some very bad shit happened to my mysql databases. Fortunately I had backups and only 1 day was lost. However, I realized that having something to do diff on tables would be very helpful. I can compare raw dumps using text editors and comparison tools but that's not a really cool way to do it. I would be very grateful for any tips and suggestions.
:helpme

woj 04-05-2017 01:16 PM

you don't need any "tool", just run a query using the 2 tables...
most straight forward way is probably to "LEFT JOIN" on id fields on the 2 tables and then search for "table2.id IS NULL" that will find any missing rows...

Barry-xlovecam 04-05-2017 06:02 PM

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

Code:

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:

Code:

diff -y --suppress-common-lines /tmp/dump1 /tmp/dump2
diff - How do I see the differences between 2 MySQL dumps? - Stack Overflow

Interesting thread you would have to try and see ...

see: $ man diff


All times are GMT -7. The time now is 01:19 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123