Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a symlink for the libmysqlclient.18.dylib library

Tags:

mysql

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.

like image 493
Petran Avatar asked Nov 11 '15 17:11

Petran


4 Answers

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.

like image 93
eareese Avatar answered Oct 16 '22 00:10

eareese


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.

like image 39
Giuseppe Avatar answered Oct 16 '22 02:10

Giuseppe


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!

like image 3
Swanky Coder Avatar answered Oct 16 '22 02:10

Swanky Coder


  1. Uninstall mysqlclient
  2. Clear cache of your pip
  3. Find folder in which pip wheel cache is stored for mysqlclient and delete it.
  4. Reinstall mysqlclient

mac mojave OS cache will be in this folder: ~/Library/Caches/pip. Follow the steps below:

  1. Find ~/Library/Caches/pips/wheels/ | grep mysql
  2. Delete the file you got.
  3. pip install mysqlclient
like image 1
Ashish Muralidharan Avatar answered Oct 16 '22 01:10

Ashish Muralidharan