需要gcc,所以先安装gcc
yum install gcc python-devel
安装Python中的easy_install工具,它的作用类似于Ruby中gem
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | python
下载MySQL-python
wget --no-check-certificate http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz
tar -zxvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
vi site.cfg
把 mysql_config = /usr/local/mysql/bin/mysql_config 这一行前的#去掉,并且把mysql_config的路径设置正确。
python setup.py build
python setup.py install
如果gcc没有发现,则运行
yum install gcc python-devel
运行python
>>> import MySQLdb
无错误,则表示成功了
easy_install MySQL-python
easy_install MySQL-python --upgrade
运行python
>>> import MySQLdb
无错误,则表示成功了