Getting MySQLdb up and running on Snow Leopard with MAMP
OK this is another post that is more for my own future sanity than anything else. This has been a huge pain in the ass for me many times and I want to document the steps I took to get this working.
First, this is a good general overview
http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/
So I downloaded/installed MySQL, then I had to add it to my PATH var to get the MySQLdb install to work.
//Open With textmate
mate ~/.profile
export PATH=”/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH”
then make sure you update your profile or close and open a new terminal window
source ~/.profile
that will let the MySQLdb install work. Then when you run Python and try to use MySQL db you’ll get errors. What you need to do is the following:
change your PATH to export PATH=/Applications/MAMP/Library/bin:$PATH
which links to MAMP mysql, then run this command
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
Then you should be good to go. Might be able to skip the first step but I don’t know if the MySQL that comes with mamp is 64bit and you need 64 bit for snow leopards install of Python..
Why is python such a pain in the ass?
Fuc* MySQLdb. I am going back to old sweet php.
I had MySQLdb working before, but it wouldn’t connect to the MAMP MySQL server.
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
did the trick, thanks!
JS
Yes! This step kils me every time, glad I could help someone else out!
I was get “EnvironmentError: mysql_config not found” so I changed the mysql_config path in the site.cfg file in python to /Applications/MAMP/Library/bin/mysql_config and uncommented the line. This worked for the build and the install i hope this helps.