How to install Perl DBD on Mac OS X Mavericks with MAMP Stack

Today I decided to work on Honeyd-Viz a bit which I feel I have abandoned the last year. In order to do so, I needed to have a sample database to play with. As you know, you can create a MySQL database with entries from Honeyd’s honeyd.log file using the Honeyd2MySQL script. Honeyd2MySQL uses Perl’s DBI::DBD module for MySQL operations. I have also been using MAMP Stack from BitNami for development. The problem I had was the installation of DBI::DBD on my Mac OS X which I needed in order to use the DBD::mysql driver. If you’re having troubles you can follow the guide below (written with some help from StackOverflow):

  1. Install XCode from the App Store. Then, open XCode, go to the Preferences –> Downloads menu and install the Command Line Tools.

  2. Install MAMP Stack from BitNami. Write down or take a mental note of the password value for MySQL’s root user. Choose to start the services (Apache & MySQL).

  3. Add MAMP’s MySQL binaries to your PATH (this is particularly needed for mysql_config). Example:

    locate mysql_config

    Get that directory and add it to your .bash_profile file, appending it to the PATH variable:

    nano ~/.bash_profile
    PATH={ ... }:/Applications/mampstack-5.4.32-0/mysql/bin

    Logout and open a new shell session.

  4. Create symlinks for MySQL’s lib files in your local lib path:

    cd /usr/local
    mkdir lib #it might already exist, e.g. if you're using Homebrew
    cd lib
    sudo ln -s /Applications/mampstack-5.4.32-0/mysql/lib/plugin/ plugin
    sudo ln -s /Applications/mampstack-5.4.32-0/mysql/lib/*.dylib .

  5. Initialize CPAN and install cpanm:

    cpan #accept defaults
    sudo cpan App::cpanminus

  6. Install DBI and download DBD::mysql:

    sudo cpanm DBI
    sudo perl -MCPAN -e 'shell' #opens a CPAN shell session
    cpan> get DBD::mysql
    cpan> exit

  7. Manually install DBD::mysql:

    cd ~/.cpan/build/DBD*
    sudo perl Makefile.PL --testuser='root' --testpassword='<mysql_root_password>' #use the password you entered during MAMP's installation
    sudo make install

  8. (optional) Symlink your MAMP’s MySQL sock file if needed (e.g. if you get an error while trying to connect to MySQL server running on ‘localhost’):

    ln -s /Applications/mampstack-5.4.32-0/mysql/tmp/mysql.sock /tmp/mysql.sock
    chmod 777 /tmp/mysql.sock

That’s it! Hopefully everything would be good to go.


1 ping

    • Vicki Brown on November 12, 2015 at 9:21 PM
    • Reply

    Have you tried Yosemite? I’m getting errors from make test.

      • Ion on November 16, 2015 at 7:35 AM
      • Reply

      Not yet a vanilla installation, I’ve updated my Mavericks to Yosemite and it still works… I think.

    • pilot_marker on May 9, 2016 at 5:31 AM
    • Reply

    Works on El Capitan! had to do some edits on the URLs.


  1. […] Security Bloggers Network, Ioannis Koniaris, […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Read previous post:
DionaeaFR: adding parameterized date range

UPDATE: this change has been merged into the official DionaeaFR repo. As you might know, DionaeaFR is a very good frontend...