EnvironmentError: mysql_config not found

I am using Mac OS X 10.9, MAMP 1.9 (MySQL 5.1.44), Python 2.7.5.

Got this error when I change database configuration in settings.py.

I felt this issue can make me painful, so I start logging what happened and how I fixed.

Do not follow below steps. Just go straightly bottom of article and read last part.

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 25, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

Searched google and found a problem. According this article, it might be missing the MySQLdb module. So I need to install it. To install MySQLdb module, I found another article that explains how to install.

Step 1: Open shell and execute below

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

However, since I am using MAMP database, I had to set up differently as below:

export PATH=/Applications/MAMP/Library/bin:$PATH
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib/mysql

Step 2: Execute below

sudo pip install MySQL-python

However, I got the error as below:

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

According to this article, the error is causing by some Python compile issue.

So, execute below

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

And -mno-fused-madd error is gone; however, I faced another error (f**k)

cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -arch x86_64 -arch i386 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/Applications/MAMP/Library/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -fno-omit-frame-pointer -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL

_mysql.c:44:10: fatal error: 'my_config.h' file not found

#include "my_config.h"


1 error generated.

error: command 'cc' failed with exit status 1

OK, according to this article, MAMP’s version of MySQL does not contain the dev headers. Therefore, I should download headers and integrate with MAMP.

At this point, I planned to give up. However, I found this resource, which looks very relevant with this problem. (I couldn’t open original webpage; thus, the link is cached from Google)

New Step 1 Start: install XCode.

I already have XCode installed. Thus, skip this step.

Step 2: Install CMake

Open http://www.cmake.org/cmake/resources/software.html and download Mac OS X dmg file.

Install CMake.

Step 3: Stop MAMP completely


Step 4: Download MySQL header

Open http://sourceforge.net/projects/mamp/files/mamp/ and find your MAMP version.

In your MAMP version folder, you can find MAMP_components_{version}.dmg. In my case, MAMP_components_1.9.dmg

Once finish download, mount and find mysql-{version}.tar.gz in MAMP_src folder. And extract tar archive.

cd /tmp
cp /Volumes/MAMP_components_1.9/MAMP_src/mysql-5.1.44.tar.gz .
tar xzvf mysql-5.1.44.tar.gz
cd mysql-5.1.44

Run CMake with MySQL 5.1.44.

cmake . -DMYSQL_UNIX_ADDR=/Applications/MAMP/tmp/mysql/mysql.sock -DCMAKE_INSTALL_PREFIX=/Applications/MAMP/Library

Then you will get this error.

-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:24 (INCLUDE):
  include could not find load file:


-- Detected 64-bit platform.
build CSV as static library
build HEAP as static library
build MYISAM as static library
build MYISAMMRG as static library
build ARCHIVE as DLL
build EXAMPLE as DLL
-- Configuring incomplete, errors occurred!

Now, run below command and do following replace:

nano CMakeLists.txt

And find win/configure.data line, and comment out as below.

# INCLUDE(win/configure.data)

Then run below command

cmake . -DMYSQL_UNIX_ADDR=/Applications/MAMP/tmp/mysql/mysql.sock -DCMAKE_INSTALL_PREFIX=/Applications/MAMP/Library

And I got other errors. Damn… Give up this solution.

Tried to find out another solution.

I followed below. Now don’t have energy to write steps. Just go to his article and follow the step.