42

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?

maccy1
  • 523
  • 2
  • 5
  • 6

7 Answers7

60

brew install mysql fixed this for me

Peter Ehrlich
  • 6,969
  • 4
  • 49
  • 65
  • 1
    Yes, 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
34

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

edilio
  • 1,778
  • 14
  • 13
15

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

Danny Mor
  • 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
  • This solution should be rigth answer for macos. – Nebuchanazer Sep 07 '22 at 00:16
8

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
drhenner
  • 2,200
  • 18
  • 23
1

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

EdemaRuh
  • 111
  • 1
  • 6
0

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.

rvelasquez
  • 21
  • 1
0

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.)

Warren Young
  • 40,875
  • 8
  • 85
  • 101