Ahh, that’s a nice and descriptive title.
Needless to say, I had the darnest time doing this. Upgrading mysql was not too big of an issue, but getting MySQLdb to work was a whole other game.
Anyway, here are the steps I took.
The instructions for upgrading MySQL came from entropy.ch and are as follows:
- Save your current database data before doing anything:
cd /usr/local/mysql; sudo tar -cvf /tmp/mysql-data.tar data - Then download the MySQL installer from the MySQL website. At first I chose to download “Mac OS X ver. 10.6 (x86, 32-bit), DMG” which, I believe, caused all my problems with MySQLdb. So download Mac OS X ver. 10.6 (x86, 64-bit), DMG unless you know you have a 32 bit machine.
- Once downloaded, unpack and install the MySQL package and even the prefPane to make your life easier.
- To restore your old data, run this command:
cd /usr/local/mysql; sudo tar -xf /tmp/mysql-data.tar - I’m not sure if this is needed, in the attempt that worked, I followed the instructions to the dot so I did reboot my computer (although the MySQL install didn’t require me to).
- Start MySQL either through the System Preferences (if you installed the prefPane above) or by running:
sudo /usr/local/mysql/bin/mysqld_safe
That’s all there was to installing MySQL. Note that in my system I didn’t have to change the ownership of the database data when it was “imported” into the new install. If you have to do that (i.e. can’t login with the usual username/password combo) see the instructions in the link I posted above.
Now onto MySQLdb. These instructions are taken from Geert JM Vanderkelen.
- Download MySQL-python-1.2.3c1.tar.gz from the Python Package Index.
- Untar it and ensure “/usr/local/mysql/bin” is in your PATH, if not see the above link on how to add it.
- Run this command:
ARCHFLAGS="-arch x86_64" /usr/bin/python setup.py build(Ensure you don’t have a 64 bit machine before changing it.) - And finally, install it with the following command:
sudo /usr/bin/python setup.py install
Once all that is done. You can test it like this:
$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
If that gives you no errors, you’re set. Now get back to doing actual work
.