首先需要安装有setuptool,
wget -q
然后python ez_setup.py
还有确定是否安装了python-devel包
安装包下载
解压后修改site.cfg文件
[options]
# embedded: link against the embedded server library
# threadsafe: use the threadsafe client
# static: link against a static library (probably required for embedded)
embedded = False
threadsafe = True
static = False
# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
#需要指定mysql安装位置中的配置程序
mysql_config = /usr/local/bin/mysql_config
# The Windows registry key for MySQL.
# This has to be set for Windows builds to work.
# Only change this if you have a different version.
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
如果在编译到最后时,报告链接不上libmysqlclient_r.so的话,还需要把threadsafe设置为False。
然后
python setup.py build
python setup.py install
安装完成后
如果在import MySQLdb时出现importError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory错误
需要export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH
另外如果出现包含解压目录的警告信息的话,需要删除解压目录,即可正常