简体   繁体   中英

perl DBD::mysql not working with mysql 5.6?

I installed MySQL 5.6.10 onto Mac OSX 10.8.2, in /usr/local/mysql-5.6.10-osx10.7-x86_64/. I then tried to run a Perl program that connects to a MySQL database using DBI and DBD::mysql. I got the following errors:

install_driver(mysql) failed: Can't load '/Users/chap/perl5/perlbrew/perls/perl-
5.16.1/lib/site_perl/5.16.1/darwin-2level/auto/DBD/mysql/mysql.bundle' 
for module DBD::mysql: dlopen(/Users/chap/perl5/perlbrew/perls/perl-
5.16.1/lib/site_perl/5.16.1/darwin-2level/auto/DBD/mysql/mysql.bundle, 
1): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib

Perhaps a required shared library or dll isn't installed where expected

(This worked fine when I had used 'brew' (not related to perlbrew) to install mysql 5.5 into its own directory, /usr/local/Cellar/. Since brew doesn't yet know about 5.6, I installed it manually.)

I'm able to start mysqld and connect successfully from mysql command line. Does this error indicate that there's a problem with Perl's DBD::mysql module? It's up-to-date; maybe it can't talk to MySqL 5.6?

Thanks!

I have had several problems installing DBD::mysql on Mac, and I found the following to work on Mac OSX 10.6.8 with Perl 5.16.1 and MySQL 5.5.27 where mysql is installed in /usr/local/. Please double check any paths and usernames used in the commands below.

export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH


curl -kL http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.021.tar.gz > DBD-mysql-4.021.tar.gz
gunzip -c DBD-mysql-4.021.tar.gz | tar xopf - 

cd DBD-mysql-4.021 && perl ./Makefile.pl --testuser root --libs="-L/usr/local/mysql/lib -lmysqlclient -lpthread"

install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib blib/arch/auto/DBD/mysql/mysql.bundle

make test
sudo make install

And then check with a connection (assuming you still have the test database and the anonymous user enabled)

perl -e "use DBD::mysql; my $dbh = DBI->connect('dbi:mysql:test:localhost::3306:mysql_socket=/tmp/mysql.sock'); $dbh->disconnect();"

This person solved your issue by installing DBD::mysql and DBI manually instead of via CPAN:

http://forums.mysql.com/read.php?51,281769,282127#msg-282127

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM