This is a brief post on how to get Perl's DBD::mysql working with MAMP 1.7 on Mac OS X Leopard. The instructions for now, are quite concise.
I have found that using CPAN does not seem to work to install DBD::mysql when you only have MAMP installed. The CPAN commands:
perl -MCPAN -eshell install DBD::mysql
This I think is due to MAMP not having the correct MySQL files or libraries installed. Below are the steps required to get DBD::mysql working.
Note: You will probably need XCode tools installed to be able to compile the MySQL libraries.
1. Install the header files
Download the full MAMP packages.
The file that you need is called something like MAMP_1.7_intel_full.dmg.
This image contains the required files. Copy:
cp -r /Volumes/MAMP/MAMP/Library/include /Applications/MAMP/Library
2. Install the MySQL client libraries
- Download the MAMP sources. MAMP_1.7_src.tar.gz
- Untar
- Untar the mysql archive file
- Change directory to the mysql directory
- Configure and build mysql
./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock \ --without-server \ --prefix=/Applications/MAMP/Library make -j2
- Copy libraries
cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql
3. Build and install DBD::mysql
- Download DBD-mysql-4.006.tar.gz or similar from CPAN. (Or use the one in ~/.cpan/build/DBD-mysql-4.006)
- Build
perl Makefile.PL --CFLAGS="-I/Applications/MAMP/Library/include/mysql -Os -arch i386 -fno-common" \ --libs="-L/Applications/MAMP/Library/lib/mysql -lmysqlclient -lz -lm" \ --mysql_config="/Applications/MAMP/Library/bin/mysql_config" make make test sudo make install
Make test may throws errors about connecting to the database server but should not throw an errors about using shared libraries or missing symbols.