Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with Perl DBI/DBD on OSX 10.9 Mavericks

After upgrading to OSX Mavericks I can't get DBI/DBD to run.

Perl and MySQL are running fine (I can login to mysql and access my tables), but my Perl scripts can't use DBI anymore as the updater removed all of my previously working Perl modules.

I reinstalled DBI and DBD::mysql using CPAN, which installed them to /opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level/. After copying the modules (DBI, DBD and everything in "auto") to /Library/Perl/5.16/darwin-multi-2level/ (as the dir used by cpan is not in @INC) my scripts return an Internal Server Error (even with FatalsToBrowser).

The Apache error log says:

dyld: lazy symbol binding failed: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level/auto/DBI/DBI.bundle
Expected in: flat namespace

dyld: Symbol not found: _Perl_Istack_sp_ptr
Referenced from: /opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level/auto/DBI/DBI.bundle
Expected in: flat namespace
Premature end of script headers: test.pl

What's the problem here? Maybe because I copied the files? Maybe I should force CPAN to install to /Library/Perl/5.16/ directly? How can I tell CPAN to do so?

Any ideas?

like image 488
marluxor Avatar asked Oct 24 '13 12:10

marluxor


1 Answers

I haven't upgraded to Mavericks because Apple doesn't care about the modifications one does to Apache, PHP or Perl when upgrading the OS – they just remove them all. I don't know if the following list is going to work well for you, but it worked for me with Lion and Mountain Lion:

  • You must have MySQL x86 64-bit properly installed and configured before starting.
  • Install XCode from the App Store.
  • In XCode, open the Preferences / Downloads menu and then install the Command Line Tools.

Install DBI:

  • Install cpanm with this command: sudo cpan App::cpanminus.
  • Install DBI: sudo cpanm DBI.

Install DBD::mysql:

  • Get the necessary files from CPAN. Open the CPAN terminal: sudo perl -MCPAN -e 'shell'.
  • Then, run these commands: get DBD::mysql and exit.
  • Before compiling you have to create some alias because MySQL on Mac is installed differently than on Linux – at least this was true in the previous OS X versions:

cd /usr/local

sudo mkdir lib

cd lib

sudo ln -s /usr/local/mysql/lib/*.dylib .

  • Finally, you must install and compile the library:

cd ~/.cpan/build/DBD*/

sudo perl Makefile.PL --testuser='yourmysqluser' --testpassword='yourmysqlpassword'

sudo make

sudo make test

sudo make install

At cd ~/.cpan/build/DBD*/, by the *, I mean that you should write the actual path that goes to the files you just downloaded from CPAN. The name of the directory changes depending on the lastest version but it's easy to find it with a simple ls.

Hope this works for you.


EDIT

This was a compilation I made through several failed attempts, but I think I should name my sources:

http://bixsolutions.net/forum/thread-8.html

http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion

Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in

like image 62
calvillo Avatar answered Sep 27 '22 16:09

calvillo