Problems with Perl DBI/DBD on OSX 10.9 Mavericks
Asked Answered
B

7

7

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?

Bonnes answered 24/10, 2013 at 12:9 Comment(2)
I just tried to remove and reinstall DBI/DBD and added use lib "/opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level" to my script , but this doesn't fix it...Bonnes
Please refrain from answering your question in the question, instead post it as an answer. I posted your answer as a community-wiki for you.Exalted
L
10

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

Lynlyncean answered 24/10, 2013 at 12:57 Comment(5)
Thanks for your feedback, it was a quite different problem (mixed up Perl versions), check my edit above for details.Bonnes
Thanks - that's it. But, I only did the symlinks and then continued with cpan.Shalom
Isn't this line missing something: sudo ln -s /usr/local/mysql/lib/*.dylib ? Shouldn't there be a second path there?Rudd
Yes, as per this comment there should be an extra space and period on the end of the line, so: sudo ln -s /usr/local/mysql/lib/*.dylib . With that this all worked for me - thanks!Rudd
Yes, Phil. Sorry about that, it seems like I couldn't see it in my notes. I just corrected it.Lynlyncean
T
2

The info with 5.12 and 5.16 is spot on. To fix, upgrade CPAN and reinstall the modules:

sudo cpan
install CPAN
reload cpan
install <module>
Telophase answered 3/11, 2013 at 21:59 Comment(0)
E
0

Mavericks installs Perl 5.16, while it doesn't delete the previous 5.12 binaries. Additionally I had installed some other software, which kept a further copy of Perl 5.12 under /opt/local/bin (I think it was MacPorts, I probably used it to install cpan), and this directory was listed in my bash profile.

This means that CPAN used 5.12 to compile the binaries while Apache used 5.16, this is why some things worked in the terminal while web scripts crashed.

Removing /opt/local/bin from $PATH and reinstalling DBI and DBD manually finally fixed the problem.

Exalted answered 24/10, 2013 at 12:10 Comment(0)
F
0

I had an existing MySQL configuration when I upgraded to OS X 10.9, with a custom port (I use Boxen). By far the easiest route for me, which worked flawlessly was a source installation.

# extract the archive, etc.    
perl Makefile.PL --testuser=myuser --testpassword=pass --testport=13306
make
make test
# if all went well with the test
make install
Frugivorous answered 14/11, 2013 at 21:35 Comment(0)
L
0

I faced this issue too on Mavericks OS. The solution that worked for me was a mixture of some things I saw on the net:

  1. Install the latest version of Command Line Tools (apple web developers site):
    $sudo perl -MCPAN -e shell

  2. Re install with cpan the DBI and DBD:mysql modules. I faced an issue here with the lipo crashing.

  3. Work with the latest version of CommandLineTools lipo:
    $sudo mv /usr/bin/lipo /usr/bin/lipo.orig
    $sudo ln -s /Library/Developer/CommandLineTools/usr/bin/lipo /usr/bin

  4. Finally reinstall DBI , DBD:mysql modules using cpan install DBI , cpan install DBD::mysql

Luba answered 26/11, 2013 at 2:37 Comment(0)
L
0

For me I ended up uninstalling MySql completely and installing an older 32-bit version instead as explained in this stackoverflow page: MySQL pid ended (cannot start mysql)

Then you need to get Perl to run in-32 bit mode only by entering the following into terminal (credit to Simon at AskDifferent):

defaults write com.apple.versioner.perl Prefer-32-Bit -bool yes
Lubricator answered 17/8, 2014 at 13:17 Comment(0)
K
0

I had problems for several months under High Sierra trying get DBI::mysql to work with no joy. I found a solution at this link:

Trouble installing DBD::mysql under macOS Mojave

What worked for me: 1. brew install openssl mysql-connector-c 2. sudo cpan install DBD::mysql

Kalidasa answered 18/1, 2020 at 23:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.