Forwarding Address: OS X

Thursday, February 27, 2003

Fun with Perl, DBI and mysql
I just spent a nice afternoon reinstalling perl (who knew that the multithreaded version of 5.8 didn't work with DBI? Ok, a lot of people but not me), installing DBI and the MySQL DBD driver. "Great", think I, "now I'm ready to go." I grab "Programming the Perl DBI" and dive in... to a bone-dry pool. No connection to my database, no idea why.

Turns out that the connection for mysql is subtly different than that for msql (I don't know why I thought they might be similar; a whimsical moment of hopefulness I suppose). In "PtPDBI" they describe the msql connect as:

dbi:mSQL:hostname:database:port
but for mysql it must be:
dbi:mysql:host=hostname:db=database:port
Took me almost an hour of googling to hunt that little tidbit down, buried deep in someone else's question on some mailing list somewhere. So as a public service I now archive it here for you. Discuss