1. Perl
  2. Module
  3. here

MySQL::Diff - Check the differences in the MySQL database

When I was looking for a tool to automatically generate commands to eliminate diffs from MySQL database diffs, I found a module called MySQL::Diff . This module comes with a command line tool called mysqldiff, so it's usually best to use it.

It doesn't show all the differences, it seems to be only the part related to the table definition, so it seems that you need to set the trigger and index yourself.

The documentation doesn't seem to explain the options, so you can check with the - help command.

mysqldiff - help

First, let's get the table definition of the database with mysqldump. Let's assume you're in a development environment and you're making changes to the database server in your development environment.

mysqldump -d -uken db> db_devel

Let's assume you can connect to the production environment with ssh. Then execute the command with ssh and redirect.

ssh ken @remotehost mysqldump -d -uken db> db_production

Since mysqldiff uses the database temporarily, you need to specify the database information.

mysqldiff - host = localhost - user = ken - password = ppp db_production db_devel

Then, the command to match db_production to db_devel is output.

# # mysqldiff 0.43
# #
# # Run on Sun Nov 27 15:57:54 2011
# # Options: user = root, debug = 0
# #
# # - - file: db_production
# # +++ file: db_devel

CREATE TABLE book (CREATE TABLE book)
  id int(11) default NULL
) ENGINE = MyISAM DEFAULT CHARSET = latin1;

Note that if you make a mistake in the order of db_production and db_devel, the opposite command will be generated.

Related Informatrion