DBD::mysql on Leopard with _mysql_init errors

It was over four years ago that I first had problems installing the DBD::mysql Perl module on Mac OS X 10.3 Panther. Some things don’t change for the better and I spent most of this afternoon struggling to get up and running DBD::mysql on Mac OS X 10.5 Leopard.

I apparently installed both DBI and DBD::mysql fine but when I tried to access the Movable Type CGIs I was trying to run I’d only see Internal Server Errors and this in the Apache error log:

dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: dynamic lookup

dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: dynamic lookup

Premature end of script headers: mt.cgi

I did a lot of Googling and found many people with similar problems with “_mysql_init” while trying to get Ruby working, but precious little concerning Perl. The Ruby solutions pointed toward it being something to do with the installed version of MySQL being 64-bit rather than the 32-bit Ruby was expecting. (I know nothing about Ruby, so I’m waving my arms a lot here.)

Because I’d recently moved over from a G4 PowerBook to a new MacBook, using ‘Archive and Install’, my MySQL was initially a PowerPC version. First I’d tried replacing it with the packaged MySQL for “x86_64” because I had a 64-bit machine, but the same errors appeared. So I tried the plain “x86” package, assuming this would be 32-bit. The same errors.

I guessed that maybe when I originally installed DBD::mysql some configuration was set that made it think I still had the PPC version of MySQL installed. So I deleted DBD::mysql:

sudo rm /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD
sudo rm /Library/Perl/5.8.8/darwin-thread-multi-2level/DBD

(If you have other DBD::somethings installed you should probably delete …/DBD/mysql rather than the whole …/DBD directories.)

Then I installed DBD::mysql again and, hurrah, mt.cgi finally worked.

You should make sure you have /usr/local/mysql/bin in your $PATH — put this in your ~/.bash_profile:

export PATH=/usr/local/mysql/bin:$PATH

Then when you install DBD::mysql it picks up the appropriate settings from mysql_config, including setting which version of MySQL you’re using. So make sure you have the correct MySQL installed before installing DBD::mysql. Unlike me.

Thanks to Mike T and Brad Choate for saving my sanity and I hope this saves at least one other person an afternoon of swearing at Google.

Comments

  • Phil,

    I realize it was a while ago you wrote this, and the topic may not interest you anymore. But if you can turn your mind to this issue once more, I'd appreciate your thoughts.

    I also am getting an Internal Server Error from Movable Type, and exactly the same error in the Apache log file that you give above.

    I'm trying to get Movable Type installed on a recently purchased Macbook Pro, with a fresh install of Snow Leopard. I've never had Movable Type or mysql installed before. I installed mysql-5.1.39-osx10.5-x86.dmg and it runs fine. I've tried several installations of various things and I'm a little hazy on the order now, but I think I installed DBI-1.609.tar.gz and DBD-mysql-4.013.tar.gz manually from the cpan site. I probably did not have /usr/local/mysql/bin in my PATH when doing these installs, but added it afterwards. When I got the Internal Server Error from Movable Type and the Apache errors as you described, I found your post and tried deleting everything in /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD and ... level/DBD, and reinstalling. Still the same error. In installing DBD-mysql, 'make test' gives a link error, which I find quite strange because the missing reference is from one file in the DBD-mysql distribution to another, as follows:

    # Error: Can't load '/Library/Perl/DBD-mysql-4.013/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/DBD-mysql-4.013/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _is_prefix
    # Referenced from: /Library/Perl/DBD-mysql-4.013/blib/arch/auto/DBD/mysql/mysql.bundle

    Do you have any ideas on how I might track down the issue?

    Thanks,

    Jim

  • Hi Jim,

    I'm afraid I haven't thought about any of this in a year and I'd be starting everything over from scratch to try and work it out. Sorry I can't help further - maybe try the MT forums?

Commenting is disabled on posts once they’re 30 days old.

Thursday 20 November 2008, 11:50pm

< PreviousIn all of WritingNext >

20 Nov 2008 in Photos

20 Nov 2008 at Twitter

  • 8:54pm: Upstairs. Noticed the computer downstairs was online. Wondered why. Realised it woke itself up to record 'The Daily Show'. Clever thing.
  • 7:12pm: @plasticbagUK I fear I'm way too locked in to actually make the switch -- many blogs and many, many templates -- but nngghhhh....
  • 7:02pm: Idly wondering about entirely ditching Movable Type for WordPress just so I never, ever have to wrestle with Perl again.
  • 4:55pm: How can it still be this hard to get DBD::mysql working on a Mac. "Symbol not found: _mysql_init" Why's it always so hard?
  • 9:44am: Haven't felt 100% for a couple of weeks now: groggy with sore throat. DESPITE new shoes. Weird.

20 Nov 2008 in Links