Does OSX need an install of libmysqlclient15-dev? I'm trying to compile a gem that is failing and a lot of sources says to install "libmysqlclient15-dev" but I only see this for Linux, not OSX. Am I missing something here?
7 Answers
brew install mysql
fixed this for me

- 6,969
- 4
- 49
- 65
-
1Yes, that's yet another way to get the MySQL C API libraries on OS X. It has one big advantage over Fink, which is that it installs things into `/usr/local`, where other packages are likely to look already, without needing any special hints. – Warren Young Jun 01 '12 at 23:05
-
I love you man ! I can't express you sved me today – Abhinav Kumar Jul 08 '21 at 14:46
-
This approach is like, you need a vehicle for daily uses and you bought a truck :) – Hossein Torabi Jul 26 '22 at 11:15
I know this is old, but google got me here. So let's say the solution in 2018 for python3 on OSX.
brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install mysqlclient

- 1,778
- 14
- 13
-
1I can't express in words my love to you, I'd been stuck with this error for 3 days. Thank you! – Guillermo Aguirre Aug 31 '18 at 13:02
-
1this mostly ran except pip install failed with `ld: library not found for -lssl` – Mobigital Dec 17 '18 at 22:40
-
1@Mobigital same error here, did you find the solution? Stuck on `ld: library not found for -lssl` – clopez Apr 04 '19 at 20:59
-
-
-
openssl was installed but gem mysql2 didn't want to install make was crashing on attempt to link importlib_openssl. the solution with install mysql-client and brew link mysql --force helped. thank you – sergey.radov Nov 03 '19 at 19:01
I just had the same problem and only got a partial working solution. Here are the steps I made to make it work:
brew install mysql-client
brew install mysql-connector-c
IF YOU HAVE ZSH:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
ELSE:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Now for the installation itself:
LDFLAGS=-L<
your openssl lib folder location> pip install mysqlclient==<
version>
for example:
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient==1.3.12

- 1,143
- 12
- 12
-
The above should be an answer to a generic "How to install MySQLdb library in Python3 (venv) on MacOS using brew" - However, as of 16 May, 2021, brew vanilla installs in /opt/homebrew, and mysql-connector-c and mysql-client have now been merged, so in short, `brew install mysql-client`, then follow the same ZSH/BASH recommendation, and change the path to `/opt/homebrew/opt/mysql-client/bin:$PATH` instead. – Speedbird May 17 '21 at 00:32
-
If you are using the mysql dmg file to install mysql you will need to edit your ~/.bash_profile and include this:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

- 2,200
- 18
- 23
-
You got no idea how headache you just saved me with this, THANKS ALOT @drhenner – Paullo Aug 13 '18 at 12:02
brew install mysql
then
arch -x86_64 gem install mysql2 -v 0.5.3 -- --srcdir=/usr/local/mysql/include
Afterwards I was able to run bundle install
.
Copied from Bragadeesh Jegannathan's blog post

- 111
- 1
- 6
Yes you will need to install this. For example if you are trying to install the mysql gem you will need the headers for the mysql library. This is because some gems need to compile native extensions, so they need the header files for any 3rd party libraries that the extensions uses.
On Mac OS X I recommend using MacPorts to manage the installation of these libraries/headers.

- 21
- 1
Those instructions are for Debian type Linuxes. The closest thing to Debian for OS X is Fink. After getting that installed and set up, you can say fink install mysql-unified-dev
to get essentially the same thing as asking for libmysqlclient15-dev
on a Debian or Ubuntu type system.
Beware that Fink installs its packages in /sw
, and not all build scripts know to look there for libraries and headers. You might have to give custom build options to get it to figure this out.
A path that may be more successful is to simply download the MySQL 5.0 package for Mac OS X. That should include the same development files as libmysqlclient15-dev
, and as a bonus will put them in places more likely to be found by your gem.
(Why 5.0, by the way? Because that's what corresponds to ABI version 15, which your package apparently requires. Maybe it will in fact work with 5.1, or 5.4, or 6.0, but that would be a risk you'd have to decide to take on your own.)

- 40,875
- 8
- 85
- 101