5

I encountered the following error while trying to run a perl script that uses DBI after upgrading to El Capitan (typical!):

install_driver(mysql) failed: 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: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle with restricted binary at /System/Library/Perl/5.18/darwin-thread-multi-2level/DynaLoader.pm line 194.

After seeing a solution posted for a similar problem in python here I have posted the same solution for Perl below.

Community
  • 1
  • 1
dan j
  • 157
  • 1
  • 11

2 Answers2

5

El Capitan's system integrity protection prevents programs in protected locations (in this case /usr) from calling a shared library that uses a relative reference to another shared library. The following solved it for me. Note, my mysql is installed via brew.

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/Cellar/mysql/5.6.26/lib/libmysqlclient.18.dylib /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
dan j
  • 157
  • 1
  • 11
0

You can also install mysql, or its open source alternative mariadb, with the "brew" tool. This avoids giving the above issue on El Capitan

$ brew install mysql

or

$ brew install mariadb

You can find brew at http://brew.sh/

Undo
  • 25,519
  • 37
  • 106
  • 129