'Django on Mac OS X requires install of MySQLdb

I tried setting up Django to use a MySQL database and it choked because the backend was not available. Reading around the net I see that MySQLdb needs to be installed, and perhaps _mysql needs to be installed as well. I have been surprised that so many different sets of instructions are available, which all seem to do different things in the install process. There are also a large number of posts about the problems with installing MySQLdb, and frequent comments about the install being a PIA. This gives me pause, as I imagine that arbitrary choices which I may make may cause random and hard to track down bugs.

Is there a consensus on what the most reliable install method is?

I don't mind configuration issues. I'm just hoping not to create original problems. As a general rant, with MySQL being so common of a DBMS, why isn't the backend already installed in Django?



Solution 1:[1]

I use Homebrew to install stuff like MySQL. It's pretty simple:

  1. Install Homebrew:

     ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
    
  2. Install MySQL using Homebrew:

     brew install mysql
    
  3. Install the MySQL Python module using your preferred Python installation mechanism (I prefer using Pip):

     pip install MySQL-python
    

As a general rant, with MySQL being so common of a DBMS, why isn't the backend already installed in Django?

You can use other database backends with Django (SQLite or PostgreSQL, for example), and the MySQL connector itself is a module installed outside of Django (and potentially used by other software -- it many cases it might already be installed).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Glorfindel