#!/usr/bin/perl -w use strict; use DBI; # just configuration -- change according to your needs, # or use a config file my $DBD = "mysql"; # change to your DBD driver my $local_database = "monks"; my $local_host ="IP_development_DB"; my $remote_database = "monks"; my $remote_host="IP_production_DB"; my $local_password = "locsecret"; my $remote_password = "remsecret"; my $local_username = "locuser"; my $remote_username = "remuser"; my $local_DSN = "DBI:$DBD:$local_database;host=$local_host"; my $remote_DSN = "DBI:$DBD:$remote_database;host=$remote_host"; # end configuration my $local_dbh=DBI->connect($local_DSN, $local_username, $local_password, {RaiseError => 1}); my $remote_dbh=DBI->connect($remote_DSN, $remote_username, $remote_password, {RaiseError => 1}); my @local_tables = $local_dbh ->tables(); my @remote_tables = $remote_dbh->tables(); foreach my $table (@local_tables) { if (grep {$table eq $_} @remote_tables) { my $query = qq{ SELECT COUNT(*) FROM $table}; my $local_sth = $local_dbh->prepare( $query ); my $remote_sth = $remote_dbh->prepare( $query ); $local_sth->execute(); $remote_sth->execute(); my ($local_result) = $local_sth->fetchrow_array(); my ($remote_result) = $remote_sth->fetchrow_array(); if ($local_result != $remote_result) { print "$table: \tL ($local_result)\t", "R ($remote_result)\n"; } } else { print "missing $table\n" ; } } $local_dbh->disconnect(); $remote_dbh->disconnect();