DBD::mysql on Mac OS: Library not loaded: libmysqlclient.18.dylib

$ perl -e ‘use DBD::mysql;’
Can’t load ‘/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle’ for module DBD::mysql: dlopen(/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Reason: image not found at /System/Library/Perl/5.18/darwin-thread-multi-2level/DynaLoader.pm line 194.
at -e line 1.
Compilation failed in require at -e line 1.
BEGIN failed–compilation aborted at -e line 1.

$ otool -L /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
$ sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
$ perl -e ‘use DBD::mysql;
works like a charm now!

Leave a Reply

Your email address will not be published. Required fields are marked *

two + 4 =