1、# yum install python-devel mysql-devel zlib-devel openssl-devel
2、http://pypi.python.org/pypi/MySQL-python/#downloads 下载安装包
# wget http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz
各版本列表在:https://pypi.python.org/packages/source/M/MySQL-python/
3、http://pypi.python.org/pypi/setuptools#downloads 下载工具
# wget http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg
4、先安装工具
# sh setuptools-0.6c11-py2.4.egg
# python
>>> import setuptools
不提示错误表示成功
5、安装 MySQL-python-1.2.3.tar.gz
# tar -zxvf MySQL-python-1.2.3.tar.gz
# cd MySQL-python-1.2.3
# vi setup_posix.py
找到mysql_config.path 一行,改为mysql_config.path = "/usr/bin/mysql_config" //注意,系统该文件夹下默认有该文件,打开修改即可
# python setup.py build
# python setup.py install
# python
>>> import MySQLdb
不提示错误表示成功
若第5步提示找不到my_config.h等文件或目录,则需要安装mysql_devel:
yum install mysql_devel即可
6. python下import mysqldb
未报错则成功。