Rails + MySQL on Osx: Library Not Loaded: Libmysqlclient.18.Dylib

rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib

The solution is pretty easy; Add the library path in your ~/.bash_profile or ~/.profile file:

MYSQL=/usr/local/mysql/bin
export PATH=$PATH:$MYSQL
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

If it is still not working (this work for me):

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

There are many blogs with install_name_tool, which won't work for me because I'm on OSX Lion:

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/bin/indexer
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/bin/search

Rails on OSX 10.11 El Capitan: Library not loaded: libmysqlclient.18.dylib

The previous answer (pre El Capitan), was to create a symbolic link from mysql's lib directory for the library file into /usr/lib, like this:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

However this now produces 'operation not permitted' due to OS X's integrity controls. This can be worked around by disabling this. However a much easier solution (and one I can verify has worked) is to just symlink it into /usr/local/lib instead:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib

Good ol' Apple.

El Capitan upgrade: Library not loaded: /usr/local/lib/libmysqlclient.18.dylib

I was getting the same issue earlier on, I fixed it by reinstalling the gem mysql2.

Why do I get a Library not loaded: libmysqlclient.18.dylib error?

The syntax should be: rake db:migrate, and not rake: dbmigrate or rake db migrate.

rails-mysql rake db :create - Library not loaded libmysqlclient.20.dylib image not found

The fix was to

gem uninstall mysql2

then reinstall it again with

bundle  # gem install mysql2 would also work

This recompiles and resolves the reference that had been left over from having mysql 5.7.9 installed.



Related Topics



Leave a reply



Submit