mysqldiff -- a utility for comparing MySQL database structures

What does it do?

mysqldiff is a Perl script front-end to the CPAN module MySQL::Diff which compares the data structures (i.e. table definitions) of two MySQL databases, and returns the differences as a sequence of MySQL commands suitable for piping into mysql which will transform the structure of the first database to be identical to that of the second (c.f. diff and patch). Database structures can be compared whether they are files containing table definitions or existing databases, local or remote.

N.B. The program makes no attempt to compare any of the data which may be stored in the databases. It is purely for comparing the table definitions. I have no plans to implement data comparison; it is a complex problem and I have no need of such functionality anyway. However there is another program coldiff which does this, and is based on an older program called datadiff which seems to have vanished off the 'net.

For PostgreSQL there is a similar tool called pgdiff.

Why did I write it?

Because it's damn useful :-)

Where can I download it?

Here is the latest version of mysqldiff (what's new?), and here's a _mysqldiff zsh function which implements completions for the program under zsh's new completion engine (this is or soon will be included in the latest development releases of zsh).

How do I use it?

(Any of the following examples can be performed the other way around.)

To compare table definitions in two files:

  $ mysqldiff db1.defs db2.defs

To compare table definitions in a file with a database named db2:

  $ mysqldiff db1.defs db2

To compare table definitions in two databases on a remote machine:

  $ mysqldiff --host=remote.host.com --user=myaccount db1 db2

To compare table definitions in a local database foo with a database bar on a remote machine, when a file foo already exists in the current directory, with debugging on level 4:

  $ mysqldiff --debug 4 db:foo --host2=remote.host.com --password=secret bar

How does it work?

For both of the database structures being compared, the following happens:

Known bugs

See the BUGS file in the distribution.

Wish-list

Feedback

As with all my software, all suggestions / bug reports / patches (unified or context diff only please) are very welcome; please contact me by e-mail.


Browser independent HTML! Valid CSS! Valid HTML 4.0!

Last updated: Sat Nov 1 22:37:39 2003
© 1995-2003 Adam Spiers <adam@spiers.net>