Using MySQLdb for Python

Discussion in 'Linux' started by igmcdowell, Oct 10, 2008.

  1. igmcdowell

    igmcdowell

    Joined:
    Oct 9, 2008
    Messages:
    2
    Likes Received:
    0
    I just went through a bit of a hassle to get MySQLdb for python, so thought I'd share the steps:

    1. Install gcc (needed to build)
    sudo yum install gcc
    2. Install mysql-devel (also needed to build)
    sudo yum install mysql-devel
    3. Get the appropriate MySQL tar file from http://sourceforge.net/projects/mysql-python:
    Click the first 'Download', click the download link next to mysql-python, then download the .tar.gz file (mine was MySQL-python-1.2.2.tar.gz)
    4. Extract it:
    tar -xzvf MySQL-python-1.2.2.tar.gz
    5. Build it (this will pull in yet another download):
    python setup.py build
    6. Install it:
    python setup.py install
    7. Test it:
    $ python
    >>> import MySQLdb

    Good luck!
     
    igmcdowell, Oct 10, 2008
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.