Kyle
Kyle

Reputation: 735

Comparing 2 mysql databases

I need to compare the results of two mysql dumps from a test db and a dev db. I have seen other questions on here asking similar questions but I need to be able to exclude certain fields such as 'created_at' and 'updated_at'. Has anyone done anything similar and can point me out some tools/resources than could help me out?

All help is appreciated, thank you.

Upvotes: 1

Views: 335

Answers (2)

Nick Coons
Nick Coons

Reputation: 3692

You can use MySQL's mysqldbcompare to compare two databases, which generates a diff-formatted output showing the differences. It doesn't do everything that you stated, so you'll have to take a few additional steps. Mainly:

  1. It doesn't compare two MySQL dump files. Instead, it compares databases. So if you have dump files, you'd need to create a couple of databases temporarily and import your dump files.

  2. As far as I can tell from the documentation, it doesn't allow you to exclude certain fields. So when you parse through the diff, you'd have to manually exclude those. You may be able to pipe it through grep to ignore fields that you're not concerned with.

Upvotes: 2

Xavi Nguyen
Xavi Nguyen

Reputation: 129

To exclude certain fields you just don't include it in the select statement, you can see more at https://www.w3schools.com/php/php_mysql_select.asp

for example SELECT id, firstname, lastname from users won't included created_at and SELECT id, firstname, lastname, created_at FROM users will include created_at field

Upvotes: 0

Related Questions