Monday, September 17, 2012

Installing percona-tools Using Homebrew

Try installing percona-tools using Homebrew:

brew install percona-tools

and it will throw the following error:

indika$ brew install percona-toolkit
Unsatisfied dependency: DBD::mysql
Homebrew does not provide Perl dependencies; install with:
  cpan -i DBD::mysql

The solution is to first install the DBD:mysql CPAN module manually:

cpan -i DBD::mysql

When prompted for parameters for Makefile.PL, enter the following:

Parameters for the 'perl Makefile.PL' command? [] --testuser=root

Here "root" refers to the DB user, not the system user by the same name. When I tried infall DBD:mysql without the "--testuser=<username>" option on my computer, it resulted in the following error:

t/80procs.t ................. 1/29 DBD::mysql::db do failed: alter routine command denied to user ''@'localhost' for routine 'test.testproc' at t/80procs.t line 41.
DBD::mysql::db do failed: alter routine command denied to user ''@'localhost' for routine 'test.testproc' at t/80procs.t line 41.
# Looks like you planned 29 tests but ran 2.
# Looks like your test exited with 255 just after 2.

Now CD into your CPAN build directory:

cp ~/.cpan/build
ls -l

drwxr-xr-x  28 indika  staff  952 Sep 16 23:32 DBD-mysql-4.022-Sl9Tjw
drwxr-xr-x  28 indika  staff  952 Sep 16 22:59 DBD-mysql-4.022-XOJVB7
drwxr-xr-x  28 indika  staff  952 Sep 16 23:30 DBD-mysql-4.022-mnhn3t

... and make the package:

cd DBD-mysql-4.022-mnhn3t

make
make test
sudo make install

Now install percona-tools using Homebrew:

brew install percona-tools

You should see it successfully:

==> Downloading http://www.percona.com/redir/downloads/percona-toolkit/2.1.2/percona-toolkit-2.1.2.tar.gz
######################################################################## 100.0%
==> perl Makefile.PL PREFIX=/usr/local/Cellar/percona-toolkit/2.1.2
==> make
==> make test
==> make install
/usr/local/Cellar/percona-toolkit/2.1.2: 79 files, 5.6M, built in 11 seconds