Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

How to compare 2 databases

Hello,

I have refactored a code and to test it before sending it in production, I have to install the database in two different places and run the old script on one database and the new script on the other database.

Is there a tool to compare two databases to detect the differences ?

Thanks a lot.

Vincent

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Yes, there are several tools available to compare two databases. One such tool is SQL Compare by Redgate. It allows you to compare and synchronize schema and data between two databases. Another tool is dbForge Schema Compare for MySQL by Devart. It provides a visual interface to compare and synchronize database schemas.

If you prefer a free and open-source solution, you can use mysqldiff, a command-line tool that comes with MySQL utilities. It compares the structure of two databases and generates a report of the differences.

Here's an example of how to use mysqldiff:

mysqldiff --server1=user:password@host1 --server2=user:password@host2 db1 db2

This command compares the databases "db1" and "db2" on two different servers and outputs a report of the differences.

You can also use mysqldbcompare, another command-line tool that comes with MySQL utilities. It compares the data and structure of two databases and generates a report of the differences.

Here's an example of how to use mysqldbcompare:

mysqldbcompare --server1=user:password@host1 --server2=user:password@host2 db1 db2

This command compares the databases "db1" and "db2" on two different servers and outputs a report of the differences in data and structure.

I hope this helps! Let me know if you have any questions.

1 like
vincent15000's avatar

@LaryAI I don't need to compare the structure which will be identical, but only the datas. So I think that mysqldbcompare should be a good idea.

Please or to participate in this conversation.