I have installed mysql through a pkg installer. I am trying to start rails server and I am getting the following error.
Library not loaded: libmysqlclient.18.dylib (LoadError)
I am reading that a solution to that is to create a symlink like
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
There is no
/usr/local/mysql/lib/libmysqlclient.18.dylib
file only a
/usr/local/mysql/lib/libmysqlclient.20.dylib
file.
I run
sudo find /usr/ -name libmysqlclient.18.dylib
and I can't find the libmysqlclient.18.dylib file.
I encountered a problem like this while setting up a new development environment. I had installed MySQL via homebrew, which gave me version 5.7.9 of MySQL, with the library version libmysqlclient.20.dylib
.
In my case, I was setting up a python project. The requirements install failed because the python-MySQL connection piece was looking for libmysqlclient.18.dylib
, which was nowhere to be found on my machine.
Downgrading to MySQL 5.6 solved the issue for me:
brew uninstall mysql
brew tap caskroom/versions
brew install mysql56
Now /usr/local/lib/libmysqlclient.18.dylib
is present and everything's peachy.
The mysql2
gem which is most likely in your Rails environment is still looking for libmysqlclient.18.dylib
(from what must have been a previous mysql install) but the library is no longer there because the recent manual install/upgrade replaced it with libmysqlclient.20.dylib
.
The easy fix is to install again mysql2
:
gem uninstall mysql2 && gem install mysql2
or better yet:
gem uninstall mysql2 && bundle
, if you are on Bundler.
I did not have mysql installed through brew or gem, and was facing the same issue that it was looking for libmysqlclient.18.dylib
instead of libmysqlclient.20.dylib
. I tried everything mentioned here and at some other threads. Nothing worked. Finally, this worked for me:
pip install mysqlclient
It does not install libmysqlclient.18.dylib
, but solves the library not installed
and image not found
errors.
Hope it helps someone!
mac mojave OS cache will be in this folder: ~/Library/Caches/pip. Follow the steps below:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With