DBI and DBD::mysql on Leopard

I needed (wanted?) to use Perl's DBD::mysql module last night. OK, I thought, a quick perl -MCPAN -eshell and install should do the trick, as Leopard's Perl usually plays quite nicely with CPAN. Damn.....error after error in the compilation (the C bit), so off to google for a fix. OMG WTF AFAIK a quick google on using Perl's DBD::mysql module in Leopard brings up a whole pile of pleading postings from desperate and frustrated people. Cutting out the clueless postings (the ones with page after page of compilation errors and pointless 'try this' - 'try that' replies), it seems the problem is nearly always the same thing: the mysql socket, or rather, it's location. Two factors conspire against you using DBD::mysql - Apple's surprise exclusion of the MySQL headers, and DBD::mysql's expectation (I think) of a hard coded location for the mysql.sock file.

To sort this mess out
1) Get Apple's 'we're sorry here's the MySQL stuff' and install it. It's at http://support.apple.com/kb/HT3370
2) Fix your php.ini file to use the same socket as DBD::mysql. I guess you could do it the other way round, but the Perl .pm module adjustment looked harder. Don't know where to find your php.ini? Shame on you! Anyway....
>php -i|grep php.ini will tell you where it lives
>nano your_location/php.ini and change mysql.default.socket = whatever DBD::mysql wants. In my case, it was /var/mysql/mysql.sock.

OK, so now everybody should be using the one socket, so
>apachectl -restart
and everything should be working. Check php -i|grep socket to make sure.

Comments

Post a Comment

Popular Posts